8000 Recursive index range expansion has unintuitive limitations · Issue #3339 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

Recursive index range expansion has unintuitive limitations #3339

@Phidica

Description

@Phidica
  • Have you checked if problem occurs with fish 2.3.1?
  • Tried fish without third-party customizations?

fish version installed: 2.3.1

OS/terminal used: Fedora 23, GNOME 3.18.2, using gnome-terminal

I'm writing a Sublime Text syntax schema for fish scripts, and have found what I suspect is a parsing bug

If an index-range-expanded-variable is used to select the index range of an outer variable, it appears that the syntax is only parsed as legal if the index-range-expanded-variable is the last or only term within the index brackets, and whitespace is significant. In the below reproduction steps, if $bar is replaced with (seq 3), the syntax is identically rejected

This seems like a fairly simple parsing error to me, since I can't imagine any good reason for these cases to be rejected. Whether the parsing can be appropriately tweaked is another matter, which I can't comment on

Reproduction steps

  1. Launch fish
  2. set foo (seq 3)
  3. set bar (seq 3)
  4. echo $foo[ 1 ]
  5. echo $foo[$bar[1]]
  6. echo $foo[1 $bar[2]]
  7. echo $foo[$bar[1] 2]
  8. echo $foo[1 $bar[2] 3]
  9. echo $foo[ $bar[1] ]

Expected results

1
1
1 2
1 2
1 2 3
1

Actual results

1
1
1 2
Invalid index value
fish: echo $foo[$bar[1] 2]
                  ^
Invalid index value
fish: echo $foo[1 $bar[2] 3]
                    ^
Invalid index value
fish: echo $foo[ $bar[1] ]
                   ^

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0