fish-shell/sphinx_doc_src/cmds/eval.rst
David Gowers 38cadc9d4f Variables as commands are in fact supported, eval docs should not claim otherwise. (#5819)
Provide an example that somewhat justifies eval's existence in light of this change.

Also correct similar misinformation found in a comment.
2019-04-26 15:30:13 +02:00

31 lines
721 B
ReStructuredText

.. _cmd-eval:
eval - evaluate the specified commands
======================================
Synopsis
--------
eval [COMMANDS...]
Description
-----------
``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.
If your command does not need access to stdin, consider using ``source`` instead.
If no piping or other compound shell constructs are required, variable-expansion-as-command, as in ``set cmd ls; $cmd``, is also an option.
Example
-------
The following code will call the ls command and truncate each filename to the first 12 characters.
::
set cmd ls \| cut -c 1-12
eval $cmd