Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Apple bash to zsh script problems with error control and bash emulation




> On 19. Nov 2020, at 14:31, Lewis Butler <lbutler@xxxxxxxxxx> wrote:
> 
> 
> On 17 Nov 2020, at 09:13, Dominik Reichardt <dominik@xxxxxxxxxxxx> wrote:
>> On 17. Nov 2020, at 16:54, Lewis Butler <lbutler@xxxxxxxxxx> wrote:
>>> 
>>> There is no reason to change a working script from bash to zsh just because the interactive shell you use has changed.
>>> 
>>> There may be other reasons to change a script for new features or better behavior (For example, I converted many sh scripts to bash because of these types of issues, but I also still have plenty of sh scripts as well).
>> 
>> 
>> Let me rephrase it:
>> I switched my interactive shell to zsh on all my machines.
>> 
>> My script did no longer work correctly even though the script invoked bash (Apple’s old bash).
> 
> Most like that would be because you did not have the same version of bash. If you installed bash via a port manager, you were running bash 5. The bash that comes with macOS is 3.2. this is almost certainly the root cause of all your issues with the scrip

I have to concede the point. I was not able to make the original script run on any prior macOS version in the 3.2x bash provided by apple. So I MUST have used bash provided by MacPorts but on some migration to a newer macOS must have lost that and completely forgot about it, too.

> 
>> My script did work correctly after I changed ti to invoke zsh without bash emulation and some fixes to make it work.
> 
> That's good, glad it is working now. But the issue of bash versions is one to keep in mind, as bash3.2 is very very old (2005?) and most bash scripts use at least some of the fixes and improvements in bash 4.x even if they haven't adopted bash 5.x changes.
> 
> I would recommend having bash5 installed as you are likely to run into other people's code that is written for bash 4.x
> 

I’ll keep it in mind when I run into problems. If I install it proactively, I will just forget again why I did it :)

Cheers,
Dom




Messages sorted by: Reverse Date, Date, Thread, Author