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

Re: sourcing a sh file in zsh

Evert Rol wrote:
> It turns out the error is indeed not in line #1, but a bit later:
>    a_temp=`egrep "^[  ]*$a_host[    ]" "$a_root/somefile"`
> If I change that line to
>    a_temp=`egrep "^[  ]*${a_host}[    ]" "$a_root/somefile"`
> the script passes fine, with exit code 0.
> So perhaps sh/bash are more lenient towards the use of braces in  
> variables. At least a quick'n'dirty test script shows this.
> I don't know; anyway can comment on that?

It's the opposite: zsh is more lenient about braces, turning $a_host[ ]
into an array expression with an incorrect subscript.  So your fix is
fine.  Having "setopt ksharrays" would fix this, and this option is used
in compatibility modes, so indeed if you were in sh emulation as
explained by Bart this will work without modification.  The emulation is
a much better general solution---there are other compatibility issues,
many of the most important of which are listed in the FAQ

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

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