In sh, is '[' a portable synonym for 'test'?
Guy Harris
guy at sun.uucp
Sun Oct 13 09:58:32 AEST 1985
>
> On my 4.2bsd system, the following do the same thing in sh because
> /bin/[ is a link to /bin/test. ... Is the "[]" form safe to use if you want
> to make something portable? My Sys5 manual (January 1983) notes the two
> forms but mentions that the second is not recognized on all systems. Does
> anybody know on what systems it will fail?
V7 systems where /bin/[ isn't a link to /bin/test. Any V7 or post-V7 system
can be made to support "if [ <condition> ]" as equivalent to "if test
<condition>", but the S5 manual properly warns you that not all systems have
been made to support it. If you want to make something portable, and you
don't think you can convince every recipient of the program to make that
link, you're best off not using "[ ... ]".
GUy Harris
More information about the Comp.unix.wizards
mailing list