mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
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`.
(cherry picked from commit 0ee24b9bce
)
This commit is contained in:
parent
fdea1abf70
commit
4b53cd583d
1 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue