what's the use of "{ list }" in /bin/sh?

WU SHI-KUEI wu at spot.Colorado.EDU
Thu Jul 7 00:43:53 AEST 1988


In article <23590 at teknowledge-vaxc.ARPA> mkhaw at teknowledge-vaxc.ARPA (Mike Khaw) writes:
>"man sh" (on ultrix) says:
>
>	{ list }
>		The list is simply executed
>
>Under what circumstances is this useful (i.e., why whould one want to
>put braces around a list of commands)?

[ -r "$filename" ] || { echo "Cannot open $filename for reading" ; exit 1 }

is another way of writing

if [ -r "$filename"
then
	echo "Cannot open $filename for reading"
	exit 1
fi

The braces are required so that both commands are executed as if one.

Carl Brandauer
ihnp4!stcvax!nbires!bdaemon!carl



More information about the Comp.unix.questions mailing list