Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.unix.questions
Subject: Re: Newlines inside command substitutions in csh
Message-ID: <4719@mimsy.UUCP>
Date: Fri, 12-Dec-86 07:43:50 EST
Article-I.D.: mimsy.4719
Posted: Fri Dec 12 07:43:50 1986
Date-Received: Sun, 14-Dec-86 19:28:52 EST
References: <640@cullvax.UUCP>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 37

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