[comp.unix.questions] Newlines inside command substitutions in csh

drw@cullvax.UUCP (12/10/86)

It seems that in Dec Ultrix 1.2 (a bsd 4.2), csh won't allow newlines
in commands that are part of a command substitution.  For example, the
command

	fgrep -l 'foo\
	bar' file

works fine, but

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

doesn't.  As far as I can tell from the manual pages, ending a line
with \ should quote the newline in all circumstances, but csh replies
"Unmatchd `".  Also, using more than one \ doesn't seem to help, so it
probably isn't that I'm not quoting the newline correctly.
-- 
Dale Worley		Cullinet Software
UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw
ARPA: cullvax!drw@eddie.mit.edu

chris@mimsy.UUCP (Chris Torek) (12/12/86)

In article <640@cullvax.UUCP> drw@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@mimsy.umd.edu