bash versus sh test builtin
Jeffrey Goldberg
jeffrey at goldmark.org
Sun Jan 11 18:08:22 PST 2009
The -ne operator for [ in /bin/sh doesn't seem to work as in bash.
Also the bash behavior here is what matches /bin/[ most closely.
$ /bin/sh
$ if [ $UID -ne 0 ] ; then
> echo not root
> fi
[: -ne: unexpected operator
$ exit
$ echo $SHELL
/usr/local/bin/bash
[jeffrey at dobby ~/src/mount-rsnap]$ if [ $UID -ne 0 ] ; then
> echo not root
> fi
not root
Does anyone have a recommendation of how to run this simple test in /
bin/sh and how to write tests reasonably portably?
-j
--
Jeffrey Goldberg http://www.goldmark.org/jeff/
More information about the freebsd-questions
mailing list