weird csh thing

The Grey Wolf greywolf at unisoft.UUCP
Wed Jan 9 12:15:47 AEST 1991


In article <BAGCHI.91Jan6000722 at snarf.eecs.umich.edu> bagchi at eecs.umich.edu (Ranjan Bagchi) writes:
>anyone care to explain??  (I`m in csh)
>
>
>$ set p = "w | tail +3 "
>$ echo $p
>w | tail +3
>$ $p
>Usage: w [ -hlsuw ] [ user ]
>$ w | tail +3
>benjo    ttyp3    10:13pm           41      4  -sh 
>benjo    ttyp4    10:17pm         3:22      4  -csh 
>$ exit
>$ exit
>
>Process shell finished
>
>
>shouldn't "$p" have the same effect as "w | tail +3" ?
>
>	-rj

Try:

% eval $p

Reasoning:

In csh, while the arguments remain individual in the case of variable
substitution, it is as though each argument has been quoted; specifically,
it is though you have requested the following command line to be executed:

% "w" "|" "tail" "+3"

The pipe is never seen by the shell.  To understand this one, try the
following:

% set p = "echo | & < >"
% $p

The same result occurs when one tries:
% set p = ( echo | & < > )
% $p

eval seems to be the only way to work around this problem.

-- 
On the 'Net:  Why are more and more fourth-level wizard(-wannabe)s trying to
invoke ninth-level magic, instead of taking the time to climb the other
(quite essential) thirteen levels so they can do this properly?
...!{ucbvax,acad,uunet,amdahl,pyramid}!unisoft!greywolf



More information about the Comp.unix.shell mailing list