This issue is to discuss removing a feature of the set command. Why? Because implementing support for tied variables (issue #4082) involves touching builtin_set(). Which is currently really hard to understand. So I wanted to refactor the src/builtin_set.cpp code into smaller components and eliminate all, or at least most, of the current lint warnings before doing the work for tied vars.
This caused me to notice a feature of the set command I was not aware of. From the man page:
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.
We don't have a single unit test for that second, alternative, syntax. Nor is there a single use in the fish project. Nor is there a single use in the Fisherman or Oh-My-Fish scripts.
This feature greatly complicates the code. It is also ambiguous and likely to be the source of errors if people actually used it. It also doesn't provide any functionality we don't already support via set PATH[1 4] /bin /sbin.
Run these two commands and examine the result: set x a b c d then set x[1 2] x[4] a. Now do set x[1 2] x[4] 1 2 3 and examine the result.
All in all I think fish 3.0 is the perfect time to remove support for this syntax.
This issue is to discuss removing a feature of the
setcommand. Why? Because implementing support for tied variables (issue #4082) involves touchingbuiltin_set(). Which is currently really hard to understand. So I wanted to refactor the src/builtin_set.cpp code into smaller components and eliminate all, or at least most, of the current lint warnings before doing the work for tied vars.This caused me to notice a feature of the
setcommand I was not aware of. From the man page:We don't have a single unit test for that second, alternative, syntax. Nor is there a single use in the fish project. Nor is there a single use in the Fisherman or Oh-My-Fish scripts.
This feature greatly complicates the code. It is also ambiguous and likely to be the source of errors if people actually used it. It also doesn't provide any functionality we don't already support via
set PATH[1 4] /bin /sbin.Run these two commands and examine the result:
set x a b c dthenset x[1 2] x[4] a. Now doset x[1 2] x[4] 1 2 3and examine the result.All in all I think fish 3.0 is the perfect time to remove support for this syntax.