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

caret positioned incorrectly or not shown in errors expanding in command position #5812

Closed
floam opened this issue Apr 11, 2019 · 4 comments
Closed
Assignees
Labels
bug
Milestone

Comments

@floam
Copy link
Member

@floam floam commented Apr 11, 2019

This happens when the expansion happens in a command position:

$ if $,asd
fish: $, is not a valid variable in fish.
if $,asd
 ^
$ command $,asd
fish: $, is not a valid variable in fish.
command $,asd
 ^

No carat at all is shown here, but one should be shown.

$ command (asd)
fish: Command substitutions not allowed
@floam floam added the bug label Apr 11, 2019
@floam floam self-assigned this Apr 11, 2019
@floam floam added this to the fish 3.1.0 milestone Apr 11, 2019
@floam
Copy link
Member Author

@floam floam commented Apr 11, 2019

Fixed:

~ $ if $,,,
fish: $, is not a valid variable in fish.
if $,,,
    ^
~ $ command (asd)
fish: Command substitutions not allowed
command (asd)
        ^

@zanchey
Copy link
Member

@zanchey zanchey commented Apr 13, 2019

The caret is still positioned wrong in non-interactive mode:

> fish -c 'echo $,foo' # correct
fish: $, is not a valid variable in fish.
echo $,foo
      ^
> fish -c 'if $,,,; end' # wrong
fish: $, is not a valid variable in fish.
if $,,,; end
 ^
> fish -c 'command (foo)' # very wrong
fish: Command substitutions not allowed
command (foo)
^

@zanchey zanchey reopened this Apr 13, 2019
@mqudsi mqudsi changed the title carat positioned incorrectly or not shown in errors expanding in command position caret positioned incorrectly or not shown in errors expanding in command position Apr 14, 2019
@floam
Copy link
Member Author

@floam floam commented Apr 16, 2019

Have you got any idea what is the big difference here between interactive and non-interactive? Most of these seem to be off by 3, as in the 3 characters of 'if '. For instance this one should be pointing under 'a':

fish -c 'if $fooo[a]; end'
fish: Invalid index value
if $fooo[a]; end
      ^

But not all parse errors in this if construct have the issue:

fish -c 'if }; end'
fish: Unexpected '}' for unopened brace expansion
if }; end
   ^

@zanchey zanchey reopened this Apr 18, 2019
@zanchey zanchey removed this from the fish 3.1.0 milestone Sep 25, 2019
@zanchey zanchey added this to the fish-future milestone Sep 25, 2019
krobelus added a commit to krobelus/fish-shell that referenced this issue Oct 4, 2019
@krobelus
Copy link
Member

@krobelus krobelus commented Oct 4, 2019

Have you got any idea what is the big difference here between interactive and non-interactive?

It seems that interactive mode is using parse_util_detect_errors to find this error, and non-interactive expand_to_command_and_args.

@zanchey zanchey removed this from the fish-future milestone Oct 20, 2019
@zanchey zanchey added this to the fish 3.1.0 milestone Oct 20, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 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

3 participants