2019-03-31 11:05:09 +02:00
|
|
|
.. _cmd-eval:
|
|
|
|
|
|
2018-12-16 17:39:33 -08:00
|
|
|
eval - evaluate the specified commands
|
2019-01-02 20:10:47 -08:00
|
|
|
======================================
|
2018-12-16 17:39:33 -08:00
|
|
|
|
2018-12-17 17:58:24 -08:00
|
|
|
Synopsis
|
|
|
|
|
--------
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2021-12-17 13:58:38 -08:00
|
|
|
**eval** [*COMMANDS*...]
|
2018-12-17 17:58:24 -08:00
|
|
|
|
2018-12-18 18:44:30 -08:00
|
|
|
Description
|
2019-01-02 20:10:47 -08:00
|
|
|
-----------
|
2021-12-17 13:58:38 -08:00
|
|
|
**eval** evaluates the specified parameters as a command.
|
|
|
|
|
If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2021-12-17 13:58:38 -08:00
|
|
|
If the command does not need access to stdin, consider using :ref:`source <cmd-source>` instead.
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2019-11-19 00:02:21 +09:00
|
|
|
If no piping or other compound shell constructs are required, variable-expansion-as-command, as in ``set cmd ls -la; $cmd``, is also an option.
|
2018-12-16 13:08:41 -08:00
|
|
|
|
2019-04-26 23:00:13 +09:30
|
|
|
Example
|
|
|
|
|
-------
|
2018-12-18 19:14:04 -08:00
|
|
|
|
2019-04-26 23:00:13 +09:30
|
|
|
The following code will call the ls command and truncate each filename to the first 12 characters.
|
2018-12-18 19:14:04 -08:00
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2019-04-26 23:00:13 +09:30
|
|
|
set cmd ls \| cut -c 1-12
|
2018-12-18 19:14:04 -08:00
|
|
|
eval $cmd
|
|
|
|
|
|