Skip to content
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

vared tmp doesn't set tmp #8836

Closed
0ion9 opened this issue Mar 27, 2022 · 1 comment · Fixed by #8837
Closed

vared tmp doesn't set tmp #8836

0ion9 opened this issue Mar 27, 2022 · 1 comment · Fixed by #8837
Labels
bug Something that's not working as intended
Milestone

Comments

@0ion9
Copy link
Contributor

0ion9 commented Mar 27, 2022

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.

@zanchey zanchey added the bug Something that's not working as intended label Mar 27, 2022
@zanchey zanchey added this to the fish-future milestone Mar 27, 2022
@zanchey
Copy link
Member

zanchey commented Mar 27, 2022

This is probably tied to the internal use of 'tmp' as a variable name.

Yep. Nice find. I think it can be rewritten to avoid using a temporary variable instead.

zanchey added a commit to zanchey/fish-shell that referenced this issue Mar 27, 2022
The tmp and prompt variables collide with variables used as arguments.
Just avoid them entirely, at the cost of making the internals of the
functions somewhat more complicated.

Closes fish-shell#8836.
@zanchey zanchey linked a pull request Mar 27, 2022 that will close this issue
3 tasks
@zanchey zanchey modified the milestones: fish-future, fish 3.5.0 Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that's not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants