Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!unisoft!greywolf From: greywolf@unisoft.UUCP (The Grey Wolf) Newsgroups: comp.unix.shell Subject: Re: weird csh thing Message-ID: <3288@unisoft.UUCP> Date: 9 Jan 91 01:15:47 GMT References: Reply-To: greywolf@unisoft.UUCP (The Grey Wolf) Organization: Foo Bar and Grill Lines: 51 In article bagchi@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