mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-23 13:11:15 -03:00
refactor set builtin
This completes the refactoring of the `set` builtin. It also removes a seemingly never used feature of the `set` command. It also eliminates all the lint warnings about this module. Fixes #4236
This commit is contained in:
@@ -44,7 +44,7 @@ The following options are available:
|
||||
|
||||
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 `PATH[1 3 7]`, only those array elements specified will be changed. When array indices are specified to `set`, multiple arguments may be used to specify additional indexes, e.g. `set PATH[1] PATH[4] /bin /sbin`. If you specify a negative index when expanding or assigning to an array variable, the index will be calculated from the end of the array. For example, the index -1 means the last index of an array.
|
||||
If the variable name is one or more array elements, such as `PATH[1 3 7]`, only those array elements specified will be changed. If you specify a negative index when expanding or assigning to an array variable, the index will be calculated from the end of the array. For example, the index -1 means the last index of an array.
|
||||
|
||||
The scoping rules when creating or updating a variable are:
|
||||
|
||||
@@ -92,3 +92,7 @@ if set python_path (type -p python)
|
||||
end
|
||||
# Outputs the path to Python if `type -p` returns true.
|
||||
\endfish
|
||||
|
||||
\subsection set-notes Notes
|
||||
|
||||
Fish versions prior to 3.0 allowed you to write `set PATH[1 4] /bin /sbin` as `set PATH[1] PATH[4] /bin /sbin`. That alternative syntax is ambiguous and inconsistent. Also, no fish script in the fish project used it. Nor could we find any 3rd-party scripts in the Oh-My-Fish or Fisherman package managers that used that alternative syntax. So it was removed in the 3.0 release.
|
||||
|
||||
Reference in New Issue
Block a user