-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove set x[1] x[2] a b
syntax
#4236
Comments
Wow... I've never heard of that. It's inconsistent with every other use of variables, with Yes, please ditch it! |
I too hadn't noticed this "feature" in the docs. I only noticed because the code I was trying to refactor didn't make any sense until I read the |
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
Done. Fish 3.0 no longer supports the alternative syntax. The |
👍 to the simplification. $ set indexes 1 2 4
$ set array a b c d e f g h
$ echo $array[$indexes]
a b d
$ echo set array[$indexes] A B D
set array[1] array[2] array[4] A B D
$ set array[$indexes] A B D
$ echo $array
A B c D e f g h The way it works is ugly but usage is pleasantly symmetrical. On master reading a var with multiple indexing still works of course, but setting errors: $ echo $array[$indexes]
a b d
$ set array[$indexes] A B D
set: You provided 1 indexes but 5 values However, this works 🎉: $ set "array[$indexes]" A B D
$ set array["$indexes"] A B D # equivalent
$ echo $array
A B c D e f g h It was quite unobvious to me EDIT: I'll send a docs PR. |
This issue is to discuss removing a feature of the
set
command. 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
set
command 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 d
thenset x[1 2] x[4] a
. Now doset 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.
The text was updated successfully, but these errors were encountered: