Newlines inside command substitutions in csh

Chris Torek chris at mimsy.UUCP
Fri Dec 12 22:43:50 AEST 1986


In article <640 at cullvax.UUCP> drw at cullvax.UUCP (Dale Worley) writes:
>... csh won't allow newlines in commands that are part of a
>command substitution. ...
>
>	echo `fgrep -l 'foo\
>	bar' file`

Csh is rather stupid about quoting and newlines.  To make this work,
use

	echo `fgrep -l 'foo\\\
	bar' file`

This is evaluated once, interally producing

	echo `fgrep -l 'foo\
	bar' file`

Then the backquote evaluator attacks it, using

	fgrep -l 'foo
	bar' file

The original command works in sh without any backslashing:

	echo `fgrep -l 'foo
	bar' file`

Incidentally, in sh you can use backquotes inside backquotes, by
quoting them once:

	eval `echo \`cat foo\``

Again, this does not work in csh.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris at mimsy.umd.edu



More information about the Comp.unix.questions mailing list