Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site phri.UUCP Path: utzoo!linus!philabs!cmcl2!phri!roy From: roy@phri.UUCP (Roy Smith) Newsgroups: net.unix-wizards Subject: In sh, is '[' a portable synonym for 'test'? Message-ID: <482@phri.UUCP> Date: Mon, 30-Sep-85 11:41:54 EDT Article-I.D.: phri.482 Posted: Mon Sep 30 11:41:54 1985 Date-Received: Wed, 2-Oct-85 20:25:51 EDT Distribution: net Organization: Public Health Research Inst. (NY, NY) Lines: 17 On my 4.2bsd system, the following do the same thing in sh because /bin/[ is a link to /bin/test. Test checks to see if it was called as "[" and in that case looks for the matching "]" at the end of the command. if test -r wombat; then echo I can read wombat; fi if [ -r wombat ]; then echo I can read wombat; fi This is not documented anywhere in the 4.2 manual (that I can find) but seems to be common practice. 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? -- Roy Smith System Administrator, Public Health Research Institute 455 First Avenue, New York, NY 10016 Brought to you by Super Global Mega Corp .com