[comp.unix.questions] eval bug

trent@cit-vax.Caltech.Edu (Ray Trent) (04/09/87)

I've noticed a rather strange behavior in BSD 4.2-3 systems' eval command.
If you put the following into a file called eval.bug:

  set noglob;
  setenv FOO '*';
  unset noglob;

and then execute the command: 

  eval `cat eval.bug` 

repeatedly, the command works *every other* time. When it fails, it
gives the message "setenv: Too many arguments" because it expands the
'*'. The commands:

  eval <eval.bug
and: 
  eval set noglob; setenv FOO '*'; unset noglob;

work just fine. The strange behavior happens because, every other
time, the command bombs out before eval'ing "unset noglob;", thus leaving
noglob set *before* every other iteration.

Bleah, that was a horrible description, let me try another tack: the
command works fine every time if you set noglob before executing it.

Is this a bug in the way `<cmd>` works, or is it a known "feature"? 

It's particularly annoying because it's sometimes convenient to do:

  setenv TERMCAP `tset -SQ vt100`

and, as we all know, the vt100 termcap entry has lots of nasty little
"["s floating around in it.
  
-- 
<this space for rent>
					../ray\..
 (trent@csvax.caltech.edu, rat@caltech.bitnet, ...seismo!cit-vax!trent)