[net.unix] Example of eval under 4.2bsd csh

kemp@noscvax.UUCP (05/31/84)

-a non-blank line-

  Here are some examples of using eval on a 4.2bsd system. (under csh).
    Does anyone have comments?

 % alias ts 'set noglob; eval `tset -s ?kaypro`'

    This line aliases the name ts to the commands which follow.
  set noglob disables filename substitution, the tset command is
  run and the output is placed in a string between the back-quotes.
  This is then taken via the eval command as input to the CURRENT shell.
    The ? before the kaypro means that the tset command will prompt
  the user for terminal type. The default will be kaypro.
    The result of all of this is that the terminal name kaypro is used
  to initialize the environment variables TERM and TERMCAP. This
  is important so that full screen editors and other commands
  work correctly.

  When tset is called like this:

 % tset -s -Q kaypro

 it produces something like the following on the standard output:
 
 set noglob;
 setenv TERM kaypro ;
 setenv TERMCAP 'Kp|kaypro|kaypro2:al=\EE:am:bl=^G:bs:cd=^W:ce=^X:cl=1^Z:cm=\E=%+\040%+\040:co#80:cr=^M:dl=\ER:do=^J:dN=50:dT=50:ho=^^:le=^H:li#24:ma=^K^P:nd=^L:';
 unset noglob;
 
   The eval statement's function is NOT to produce a truth-value, as one might
 expect, but rather to IMPORT the values into the CURRENT shell. The example
 shows then how eval can be made (via the back-quotes) to take tset's output
 and stuff it into the current shell (almost always this means LOGIN SHELL),
 thus providing an environment associated with a given terminal. This is 
 eval's reason for being.
   (It is helpful to note the effects of something like a csh script which sets
 an environment variable to some new value. The variable will remain set, 
 but only until the script terminates.  At that point the "spawned shell" 
 disappears, along with any changes in its environment, and the environment 
 reverts to whatever it was when the invoking shell gave up control. 
              - - - - - - * - - - - - -