Skip to content

vared tmp doesn't set tmp #8836

Closed
Closed

Description

@0ion9

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

  1. added
    bugSomething that's not working as intended
    on Mar 27, 2022
  2. added this to the fish-future milestone on Mar 27, 2022
  3. zanchey commented on Mar 27, 2022

    @zanchey
    Member

    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.

  4. added a commit that references this issue on Mar 27, 2022
    7c05a96
  5. linked a pull request that will close this issuevared: avoid using local variables #8837on Mar 27, 2022
  6. added a commit that references this issue on Mar 27, 2022
    fa2450d
  7. locked as resolved and limited conversation to collaborators on Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that's not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions