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

Full path with ksh emulation



Hi,

 

A large client of mine is migrating a bunch of ksh scripts to Linux that have previously run on HP-UX and Solaris and has discovered that many of them break because the standard Linux version of ksh (pdksh) creates the child on right side of a pipe rather than the left – a well documented incompatibility of the Linux ksh that shows no prospect of ever being considered a “bug” and hence no prospect of ever being “fixed”.

 

Accordingly, they have hit upon the idea of using zsh to emulate ksh.  That certainly solves the original problem, but introduces a new one.  In ksh the ‘whence’ command always gives you the absolute path of its argument.  So ‘whence $0’ always gives a full path even if the command was executed by typing ‘./myscript’.  I can find no straightforward way to do this in zsh.  Bear in mind that the scripts will run with ksh on HP-UX and Solaris – as they have for years – but will be modified to run with zsh on Linux with a command such as:

 

If [[ -z $ZSH_VERSION ]]

then

if [[ -x /usr/local/bin/zsh ]]

then

/usr/local/bin/zsh $@

exit $?

            fi

else

            emulate ksh

fi

 

Any ideas?

 

 

--Tony

 



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