BTS

Message4684

Author ft
Recipients Xk2c
Date 2013-11-17.13:41:46
Content
Thilo Six wrote:
> That is nice! I added back the logic to suppress output at user will.
>
> 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

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
History
Date User Action Args
2013-11-17 13:41:46ftsetrecipients: + Xk2c
2013-11-17 13:41:46ftlinkissue1284 messages
2013-11-17 13:41:46ftcreate