Yes, I know that the Korn shell
[[ .... ]] constructs allows it. On OpenBSD it also does and you don't need to quote it.
Code:
$ if [[ 'zzz' > 'aaa' ]]; then echo Greater ; fi
Greater
$ ls -l aaa
ls: aaa: No such file or directory
$ if [[ 'zzz' \> 'aaa' ]]; then echo Greater ; fi
ksh: syntax error: `"zzz"' missing expression operator
$
But that is not portable for
/bin/sh of for example FreeBSD:
Code:
$ echo $SHELL
/bin/sh
$ uname
FreeBSD
$ if [[ 'zzz' > 'aaa' ]]; then echo Greater ; fi
[[: not found
$ ls -l aaa
-rw-r--r-- 1 j65nko j65nko 0 Jan 1 16:39 aaa
$ if [ 'zzz' > 'aaa' ]; then echo Greater ; fi
Greater
$ ls -l aaa
-rw-r--r-- 1 j65nko j65nko 0 Jan 1 16:42 aaa
$ rm aaa
$ if [ 'zzz' \> 'aaa' ]; then echo Greater ; fi
Greater
$ ls -l aaa
ls: aaa: No such file or directory
$
But as you see, there the single
[ ...... ] works. As stated in the FreeBSD
sh(1) man page under the heading
Built-in Commands:
Code:
[ A built-in equivalent of test(1).
OpenBSD's
ksh which can be run as
sh lacks the '<' and '>' string comparison of OpenBSD's
/bin/[. This difference is documented in the manual pages of that shell, but I just did not realize that