robertd@ncoast.UUCP (Rob DeMarco) (07/03/87)
I have seen a lot of "eval" solutions. What I am wondering is exactly what does "eval" do? If I type "eval" and hit <ENTER> it just does nothing. I looked it up under "sh" in the man pages but, like always, gave confusing information. I think it stands for "evaluate". Can some one help me? [> Rd -- [=====================================] [ Rob DeMarco ] [ UUCP:decvax!cwruecmp!ncoast!robertd ] [ ] [ "I hate 'Wheel of fortune'....and ] [ proud of it!!" ] [=====================================]
lied@ihuxy.ATT.COM (Bob Lied) (07/06/87)
In article <2771@ncoast.UUCP>, robertd@ncoast.UUCP (Rob DeMarco) writes: > > I have seen a lot of "eval" solutions. What I am wondering is exactly > what does "eval" do? eval performs a second pass over the command line, performing alias and variable substitution again. For example, suppose you set a="A" b='echo $a' then if you say $b the shell expands "$b" into "echo $a", but leaves "$a" literally, so you get $a On the other hand, if you say "eval $b", the shell does one parse that yields "eval echo $a", then the eval causes a second pass, which expands $a to "A", and the result is as if you had said "echo A". Summary: a=A b='echo $a' $b ( --> 'echo $a' ) $a eval $b ( --> eval 'echo $a' --> echo A ) A Several programming languages have an 'eval' feature; Lisp, APL and m4 to name a few. The feature is generally used by setting up a string that looks like a valid statement in the language, then executing the string as if it were part of the code. Bob Lied ihnp4!ihuxy!lied