I tried to enable POSIX mode but disabled that with
#set -o posix (see the second post) when I found the POSIX documents.
While missing from POSIX
test(1), these < and > operators are in POSIX
expr(1).
With Linux
expr works:
Code:
$ if expr 'zzz' \> 'aaa' ; then echo Greater ; fi
Greater
But OpenBSD as well as FreeBSD, besides setting the error level, write a "1" or "0" followed by a <newline> to standard output, as mandated by POSIX :
Quote:
The expr utility shall evaluate the expression and write the result, followed by a <newline>, to standard output.
|
So in those BSD's you get:
Code:
$ if expr 'zzz' \> 'aaa' ; then echo Greater ; fi
1
Greater
That would mess up the output of the shell script that I was writing, unless you redirect that to
/dev/null. But I found that too messy, so I sticked with
/bin/test for now