mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 06:30:47 +08:00
1505cc3d81
darcs-hash:20060128021933-ac50b-db340075e9a57b41a91d6b64d56d9b5579185254.gz
48 lines
2.8 KiB
Plaintext
48 lines
2.8 KiB
Plaintext
\section set set - Handle environment variables.
|
|
|
|
\subsection set-synopsis Synopsis
|
|
<code>set [OPTIONS] [VARIABLE_NAME [VALUES...]]</code>
|
|
|
|
The <code>set</code> builtin causes fish to assign the variable <code>VARIABLE_NAME</code> the values <code>VALUES...</code>.
|
|
|
|
\subsection set-description Description
|
|
- <code>-e</code> or <code>--erase</code> causes the specified environment variable to be erased
|
|
- <code>-g</code> or <code>--global</code> causes the specified environment variable to be made global. If this option is not supplied, the specified variable will disappear when the current block ends
|
|
- <code>-l</code> or <code>--local</code> forces the specified environment variable to be made local to the current block, even if the variable already exists and is non-local
|
|
- <code>-n</code> or <code>--names</code> List only the names of all defined variables
|
|
- <code>-q</code> or <code>--query</code> test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
|
|
- <code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes
|
|
- <code>-U</code> or <code>--universal</code> causes the specified environment variable to be made universal. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
|
|
- <code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes
|
|
|
|
If set is called with no arguments, the names and values of all
|
|
environment variables are printed. If some of the scope or export
|
|
flags have been given, only the variables matching the specified scope
|
|
are printed.
|
|
|
|
If the \c -e or \c --erase option is specified, the variable
|
|
specified by the following arguments will be erased
|
|
|
|
If a variable is set to more than one value, the variable will be an
|
|
array with the specified elements. If a variable is set to zero
|
|
elements, it will become an array with zero elements.
|
|
|
|
If the variable name is one or more array elements, such as
|
|
<code>PATH[1 3 7]</code>, only those array elements specified will be
|
|
changed.
|
|
|
|
The set command requires all switch arguments to come before any
|
|
non-switch arguments. For example, <code>set flags -l</code> will have
|
|
the effect of setting the value of the variable <code>flags</code> to
|
|
'-l', not making the variable local.
|
|
|
|
\subsection set-example Example
|
|
|
|
<code>set -xg</code> will print all global, exported variables.
|
|
|
|
<code>set foo hi</code> sets the value of the variable foo to be hi.
|
|
|
|
<code>set -e smurf</code> removes the variable \c smurf.
|
|
|
|
<code>set PATH[4] ~/bin</code> changes the fourth element of the \c PATH array to \c ~/bin
|