eval — Construct a command by concatenating arguments
Format
eval [argument …]
tcsh shell: eval argument …
Description
The shell evaluates each argument as it would for any command. eval then concatenates the resulting strings, separated by spaces, and evaluates and executes this string in the current shell environment.
In the tcsh shell, eval treats the arguments as input to the shell and executes the resulting commands in the context of the current shell. This action is typically used to execute commands generated as the result of command or variable substitution, since parsing occurs before these substitutions. See tcsh — Invoke a C shell.
Examples
for a in 1 2 3
do
eval x$a=fred
done
sets variables x1, x2,
and x3 to fred. Then: echo $x1 $x2 $x3
produces:
fred fred fred
Usage notes
eval is a special built-in shell command.
Localization
- LANG
- LC_ALL
- LC_MESSAGES
- NLSPATH
See Localization for more information.
Exit values
- 0
- No arguments were specified, or the specified arguments were empty strings
Otherwise, the exit status of eval is the exit status of the command that eval runs.
Portability
POSIX.2, X/Open Portability Guide, UNIX systems.
Related information
exec, sh, tcsh