You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fish $version: 3.4.0-53-g3e5284aaf
OS: Arch linux x86_64
Terminal: Sakura 3.8.4
Effected by user config: No
Summary: vared specifically fails to set a variable named tmp. Any other names I have tested work correctly (ie. do set the variable.). 'Emulating' vared via set tmp (read) works correctly.
How to reproduce:
vared tmp; vared tmp2; set -S tmp tmp2
(input some values)
-> tmp is unset, tmp2 is set correctly (global var, unexported).
This is probably tied to the internal use of 'tmp' as a variable name. Changing this name to something more obscure like __vared_user_input seems to fix the problem.
Another facet of the issue is that set $argv is inadequate when the value of argv matches the name of the temporary variable (and the above 'fix' is obviously only a workaround). What vared really wants to do is set the nearest-scoped variable named by $argv that isn't of the same scope as the temporary variable. Not sure if there is actually a way to do that. It might be easier for fish to provide a mktempvar builtin, which could provide a pretty good guarantee that the generated variable name would not collide.
Activity
zanchey commentedon Mar 27, 2022
Yep. Nice find. I think it can be rewritten to avoid using a temporary variable instead.
vared: avoid using local variables
vared: avoid using local variables