Shell programming style -- a plea for better shell scripts

Guy Harris guy at rlgvax.UUCP
Sat Feb 11 08:03:15 AEST 1984


A couple of minor points:

1) /bin/[ should be linked to /bin/test (on non-USG systems) in order to make

	if [ "$1" = "foo ]
	then
		...
	else
		...
	fi

work; I have seen systems in which /bin/test (which is documented in the V7
manual) works but /bin/[ (which isn't documented, but works if the link is
made) doesn't.

2) The "#" comment convention is only in the 4.xBSD and USG shells; the
standard V7 shell only implements ":" comments - NOTE that it's not
a real comment, but a command which throws its arguments away and returns
an "exit status" of 0 (which is why "while :" works).  You can't say
things like

	: This isn't valid

because the shell gets upset at the unbalanced single quote.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix mailing list