docs: Change misleading $status comment for set

It still performs the assignment even if the command substitution
returned unsuccessfully - `set foo (echo bar; false)` returns 1 but
sets $foo to bar.

Also use `type -p` instead of `which`.
This commit is contained in:
Fabian Homborg 2017-05-19 19:06:44 +02:00
parent 64d33fac5d
commit 0ee24b9bce

View File

@ -70,7 +70,7 @@ In erase mode, if variable indices are specified, only the specified slices of t
`set` requires all options to come before any other arguments. For example, `set flags -l` will have the effect of setting the value of the variable `flags` to '-l', not making the variable local.
In assignment mode, `set` exits with a non-zero exit status if variable assignments could not be successfully performed. If the variable assignments were performed, the exit status is unchanged. This allows simultaneous capture of the output and exit status of a subcommand, e.g. `if set output (command)`. In query mode, the exit status is the number of variables that were not found. In erase mode, `set` exits with a zero exit status in case of success, with a non-zero exit status if the commandline was invalid, if the variable was write-protected or if the variable did not exist.
In assignment mode, `set` does not modify the exit status. This allows simultaneous capture of the output and exit status of a subcommand, e.g. `if set output (command)`. In query mode, the exit status is the number of variables that were not found. In erase mode, `set` exits with a zero exit status in case of success, with a non-zero exit status if the commandline was invalid, if the variable was write-protected or if the variable did not exist.
\subsection set-example Example
@ -87,8 +87,8 @@ set -e smurf
set PATH[4] ~/bin
# Changes the fourth element of the $PATH array to ~/bin
if set python_path (which python)
if set python_path (type -p python)
echo "Python is at $python_path"
end
# Outputs the path to Python if `which` returns true.
# Outputs the path to Python if `type -p` returns true.
\endfish