From 4b53cd583d82b3d37e595e19f99c6fac161e4d98 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 19 May 2017 19:06:44 +0200 Subject: [PATCH] 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 0ee24b9bce3ff9dcb29a8df60be67bfbba8669d7) --- doc_src/set.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc_src/set.txt b/doc_src/set.txt index 0b3d84173..909c093a3 100644 --- a/doc_src/set.txt +++ b/doc_src/set.txt @@ -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