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

View file

@ -1378,9 +1378,7 @@ void completer_t::perform() {
// If we are completing a variable name or a tilde expansion user name, we do that and return.
// No need for any other completions.
// Unconditionally complete variables and processes. This is a little weird since we will
// happily complete variables even in e.g. command position, despite the fact that they are
// invalid there. */
// Unconditionally complete variables and processes.
const wcstring current_token = tok_begin;
if (try_complete_variable(current_token) || try_complete_user(current_token)) {
return;