ash and bash1 shell compatibility issues
Matthias Andree
matthias.andree at gmx.de
Sat Dec 7 04:17:12 CET 2002
Hi,
some more food for the autoconf 2.57 portable shell programming section,
edit and add. This information is public domain.
----------------
This won't work in ash 0.2:
set -e
[ -d directory ] && rm -f -r directory
The shell will exit if the directory does not exist. Normally, the "set
-e" exit is to be suppressed when the failing command is in a pipe
followed by || or &&.
Use
if [ -d directory ] ; then rm -f -r directory ; else : ; fi
-----------------
It also seems that bash1 does not like
trap "if command1 ; then command2 ; else command3 ; fi" 0
It will barf with "syntax error: unexpected token then".
In my particular case, I was able to rewrite as
if command1 ; then trap "command2" 0 ; else command3 ; fi
But this is not generally possible.
--
Matthias Andree
More information about the bogofilter-dev
mailing list