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

Weird command_not_found error on subshell #5588

Closed
teresaejunior opened this issue Jan 26, 2019 · 4 comments
Closed

Weird command_not_found error on subshell #5588

teresaejunior opened this issue Jan 26, 2019 · 4 comments
Labels
Milestone

Comments

@teresaejunior
Copy link

@teresaejunior teresaejunior commented Jan 26, 2019

Fish will output an Unknown command error for each argument inside a subshell if the actual command is not found.

~> fish -c 'echs 1 2 3'
fish: Unknown command 'echs'
fish: Unknown command '1'
fish: Unknown command '2'
fish: Unknown command '3'
fish: 
echs 1 2 3
^

This error made me waste some time today because I was running fish -c from Ansible, and I thought there was a bug in my code that made each argument run in a subshell, while it was just the error output that was strange.

It doesn't try to run each argument as a command, though:

~> fish -c 'echs echo'
fish: Unknown command 'echs'
fish: Unknown command 'echo'
fish: 
echs echo
^

Behaviour on Fish 2.7.1 (well, I guess Unknown command 'echs' would be easier to understand):

fish: Unknown command 'echs 1 2 3'
fish: 
echs 1 2 3
^

Requested information:

~> fish --version
fish, versão 3.0.0

~> echo $version
3.0.0

~> uname -a
Linux laptop 4.15.0-36-generic \#39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

~> echo $TERM
xterm-256color

~> sh -c 'env HOME=$(mktemp -d) fish -c "echs 1 2 3"'
fish: Unknown command 'echs'
fish: Unknown command '1'
fish: Unknown command '2'
fish: Unknown command '3'
fish: 
echs 1 2 3
^
@faho
Copy link
Member

@faho faho commented Jan 26, 2019

Urgh, yeah. Our default command-not-found handler looks like this:

    printf "fish: Unknown command '%s'\n" (string escape -- $argv) >&2

Now guess why it displays the error multiple times.

@faho faho closed this in 02628d1 Jan 26, 2019
faho added a commit that referenced this issue Jan 26, 2019
Without it, this would print the error multiple times, like

    Unknown command: echs
    Unknown command: 1
    Unknown command: 2
    Unknown command: 3

Fixes #5588.
@faho
Copy link
Member

@faho faho commented Jan 26, 2019

Fixed in master as 02628d1 and 3.0.1 as 77b7f55.

@faho faho added this to the fish 3.0.1 milestone Jan 26, 2019
@faho faho added the bug label Jan 26, 2019
@teresaejunior
Copy link
Author

@teresaejunior teresaejunior commented Jan 26, 2019

Woah, that was fast 😄

@mqudsi
Copy link
Contributor

@mqudsi mqudsi commented Jan 27, 2019

My bad. Thanks, @faho.

floam added a commit that referenced this issue Jan 29, 2019
The previous commits to fix #5588 removed quoting.
@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants