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

"for" does not validate variable names #5800

Closed
0ion9 opened this issue Apr 8, 2019 · 3 comments
Closed

"for" does not validate variable names #5800

0ion9 opened this issue Apr 8, 2019 · 3 comments
Labels
bug
Milestone

Comments

@0ion9
Copy link
Contributor

@0ion9 0ion9 commented Apr 8, 2019

for a,b in y 1 z 3; echo $a,$b; end

Expected result: either an error or (ideally) setting a=y b=1, iterating once, then setting a=z b=3; printing each of those pairs on its own line.

Actual result: 4 blank lines

Proof of what is actually happening:

for a,b in y 1 z 3; set -l; end

Result:

a,b y
a,b 1
a,b z
a,b 3

In other words, for is assigning to a variable named "a,b".

This variable cannot be expanded (echo $a,b expands correctly to nothing ($a is not set, and therefore the product of it with ",b" is nothing)), nor can the user set, query, or erase this variable.


fish version 3.0.2-824-gbf40f84b0

@0ion9
Copy link
Contributor Author

@0ion9 0ion9 commented Apr 8, 2019

List of invalid characters that for accepts in a variable name:

,-!$#%^&*()=+[]
;:"/?.><|\`~

So, basically all of them, and in any position (for example for , in 1 2 3; set -l;end)

@0ion9 0ion9 changed the title "for" accepts and uses invalid variable names "for" does not validate variable names Apr 8, 2019
@floam
Copy link
Member

@floam floam commented Apr 8, 2019

Yeah, that's a bug. It actually is created, too, neat:

$ for a,b in a;
    set|grep 'a,b'
  end
a,b a

@floam floam added the bug label Apr 8, 2019
@floam floam added this to the fish-future milestone Apr 8, 2019
@floam
Copy link
Member

@floam floam commented Apr 8, 2019

fixed:

$ for a,j in i v; echo foo; end
fish: invalid var name: a,j
for a,j in i v; echo foo; end
    ^

@floam floam removed this from the fish-future milestone Apr 8, 2019
@floam floam added this to the fish 3.1.0 milestone Apr 8, 2019
zanchey added a commit that referenced this issue Apr 9, 2019
zanchey added a commit that referenced this issue Apr 9, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug
Projects
None yet
Development

No branches or pull requests

2 participants