Полезная информация

UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: endifChapter 5
The C Shell
Next: Reference: exec


eval args

Typically, eval is used in shell scripts, and args is a line of code that contains shell variables. eval forces variable expansion to happen first and then runs the resulting command. This "double-scanning" is useful any time shell variables contain input/output redirection symbols, aliases, or other shell variables. (For example, redirection normally happens before variable expansion, so a variable containing redirection symbols must be expanded first using eval; otherwise, the redirection symbols remain uninterpreted.) A Bourne shell example can be found under eval in Section 4. Other uses of eval are shown below and under alias.


The following lines can be placed in the .login file to set up terminal characteristics:

set noglob
eval `tset -s xterm`
unset noglob

The following commands show the effect of eval:

% set b='$a'
% set a=hello
% echo $b	Read the command line once.
% eval echo $b	Read the command line twice.

Previous: Reference: endifUNIX in a Nutshell: System V EditionNext: Reference: exec
Reference: endifBook IndexReference: exec

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System