docs: Point away from set -x

This is a common anti-pattern, we should try to get people to do `set -gx`.
This commit is contained in:
Fabian Homborg
2021-02-01 18:12:24 +01:00
parent 97be837ff5
commit 2faf814da4
3 changed files with 7 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ How do I set or clear an environment variable?
----------------------------------------------
Use the :ref:`set <cmd-set>` command::
set -x key value
set -x key value # typically set -gx key value
set -e key
Since fish 3.1 you can set an environment variable for just one command using the ``key=value some command`` syntax, like in other shells. The two lines below behave identically - unlike other shells, fish will output ``value`` both times::
@@ -18,6 +18,8 @@ Since fish 3.1 you can set an environment variable for just one command using th
key=value echo $key
begin; set -lx key value; echo $key; end
Note that "exported" is not a :ref:`scope <variables-scope>`, but an additional bit of state. A variable can be global and exported or local and exported or even universal and exported. Typically it makes sense to make an exported variable global.
How do I check whether a variable is defined?
---------------------------------------------