home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!elroy.jpl.nasa.gov!usc!sol.ctr.columbia.edu!destroyer!ubc-cs!alberta!kakwa.ucs.ualberta.ca!acs.ucalgary.ca!iwsbarke
- From: iwsbarke@acs.ucalgary.ca (I W Scott Barker)
- Subject: Re: why use eval?
- Sender: news@acs.ucalgary.ca (USENET News System)
- Message-ID: <92Aug14.215513.11933@acs.ucalgary.ca>
- Date: Fri, 14 Aug 92 21:55:13 GMT
- References: <92Aug14.195242.10973@acs.ucalgary.ca>
- Nntp-Posting-Host: acs5.acs.ucalgary.ca
- Organization: The University of Calgary, Alberta, Canada
- X-Newsreader: Tin 1.1 PL5
- Lines: 32
-
- > What is the significance of using eval `[command]`? The man pages state that
- > this runs the command [command] in the shell. Does not simply typing the
- > command alone accomplish the same thing?
-
- I believe I have figured out the use of eval. The back-quotes around a command
- cause that command to be executed in a sub-shell, after command/filename/
- variable substitution, and the resulting output is passed back to the shell as
- text. No further substitution is performed on that text. If, however, the
- back-quoted command is an argument to eval, substition IS performed on the
- resulting text. Thus, for example:
-
- alias ls 'ls -Fa'
- set foo=ls
- `echo $foo`
-
- results in a "simple" ls being performed, while
-
- alias ls 'ls -Fa'
- set foo=ls
- eval `echo $foo`
-
- results in an ls -Fa being performed, since eval caused further command
- substition to be performed.
-
- Is this correct?
-
- --
- Scott Barker
- barker@enel.ucalgary.ca
-
- "Remember, wherever you go, there you are."
- - Peter Weller, The Adventures of Buckaroo Banzai Across the 8th Dimension!
-