Gripes about /bin/sh AND /bin/csh (or, Phil's on his soapbox)

BALDWIN mike at whuxl.UUCP
Mon Jun 9 12:15:08 AEST 1986


>                                  First, there's the bit about brain-damaged
>quoting (or, non-quoting) of metacharacters.

I don't know what you're getting at here.

>                                              I'm sure a lot of you already
>know that the ability to use backquote to expand certain command strings
>just isn't there.

SVR2 /bin/sh does this right.  Pre-SVR2 had problems with the output
of builtin commands (set, export, etc).  You couldn't redirect them
or put them in back-quotes the ordinary way.

>                   'Twould be useful if one could abbreviate commands as
>variables to make one's code more legible, a la lisp.

With SVR2 /bin/sh you just set up a shell function:

	foo()	{ command I want to run; }
		and say
	foo

Pre-SVR2 you can set up a shell var:

	foo='command I want to run'
		and say
	eval $foo

>                    What's really irritating, however, is the inability to
>open and read multiple files from the shell.

You must've missed the sections on redirection and "exec" in /bin/sh.
The Bourne shell has always handled this rather cleanly!  To open
3 files (as fd's 3 4 5) and read/write stuff to them:

	exec 3<files 4<data 5>output		# open files

	while read file <&3			# read from fd3
	do	x=`line <&4`			# read from fd4
		(echo $file: $x $x) >&5		# write to fd5
	done

	exec 3<&- 4<&- 5>&-			# close files

The C shell doesn't deal with file descriptors at all.
Try to get an SVR2 /bin/sh; I think it's the best of
the standard shells.
-- 
						Michael Baldwin
			(not the opinions of)	AT&T Bell Laboratories
						{at&t}!whuxl!mike



More information about the Comp.unix mailing list