/bin/sh feature? (and, Fun With #! Lines)

chris at umcp-cs.UUCP chris at umcp-cs.UUCP
Fri Jul 27 14:25:04 AEST 1984


One annoying thing about using quoted ``hereis document'' terminators
is that /bin/sh and /bin/csh demand different conventions.  If you are
using /bin/sh, you must NOT quote the terminator.  For example,

	#! /bin/sh
	cat << 'eof'
	Hi there.
	eof

HOWEVER, if you are using /bin/csh, you HAVE to quote the terminator
(and moreover, in the same way as the original).  The script

	#! /bin/csh
	cat << \eof
	Hi.  I'll bet you're expecting this to be the only line.
	eof
	'e'of
	\eof

prints THREE lines.

[Of course, there's always the self-catting awk script:

	#! /bin/awk NR > 1 { print }

is an executable (4BSD anyway) file which prints itself, except
for the first line.

For more fun, try these scripts:

	#! /bin/rm

	#! /bin/mv

Got any other interesting scripts?]
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.unix.wizards mailing list