BTS

Message4685

Author Xk2c
Recipients ft
Date 2013-11-17.13:50:51
Content
Excerpt from Frank Terbeck:-- <snip> --
>> BUT the funny thing with this is it does work in bash but not in zsh. :/
>>
>> e.g.:
>> ~ % which cp
>> /bin/cp
>> ~ % check4progs foo cp
>> foo: binary not found
>> cp: binary not found
>>
>> This is with unmodfied debian zsh. I guess some "setopt" is missing here?
> 
> 
> Ah yes. Good catch.
> 
> The reason for this is, that zsh in its native mode of operation is very
> much *not* a POSIX shell (in particular, $foo is by default expanded as
> if you wrote "$foo" in a POSIX shell). Add the following line right at
> the top of the function. It'll enable zsh's POSIX-emulation mode locally
> in the function:
> 
>     [ -n "$ZSH_VERISON" ] && emulate -L sh

I tried this, same effect as before - it does not work.
I guess the reason is the same, since "emulate -L sh" isn't activated
'$ZSH_VERISON' will not be evaluated correctly.
Setting "emulate -L sh" prior to running the function in zsh fixes this.

> That should do the trick. The code should otherwise run in everything,
> that has ‘local’ functionality, which is basically every other POSIXly
> looking shell (like bash, ksh93, (d)ash, mksh, pksh, posh etc).
> 
> Regards, Frank
> 
> _____________________________________
> GRML issue tracker <bts@bts.grml.org>
> <http://bts.grml.org/grml/issue1284>
> _____________________________________
> 


-- 
$ \grep -Thilo '[a-zA-Z0-9._-]\+()' ~/.bashrc
History
Date User Action Args
2013-11-17 13:50:51Xk2csetrecipients: + ft
2013-11-17 13:50:51Xk2clinkissue1284 messages
2013-11-17 13:50:51Xk2ccreate