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.
This commit is contained in:
David Gowers
2019-04-26 23:00:13 +09:30
committed by Fabian Homborg
parent 22ce8c23c6
commit 38cadc9d4f
2 changed files with 6 additions and 7 deletions

View File

@@ -15,16 +15,17 @@ Description
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. Note that ``fish`` does not support the use of shell variables as direct commands; ``eval`` can be used to work around this.
The following code will call the ls command and truncate each filename to the first 12 characters.
::
set cmd ls
set cmd ls \| cut -c 1-12
eval $cmd