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

Fix status code when bad command name is entered #3616

Merged

Conversation

radomirbosak
Copy link
Contributor

Description

This commit fixes a bug which causes that

fish -c ')'; echo $status

("Illegal command name" error) returns 0. This is inconsistent with
e.g. when trying to run non-existent command:

fish -c 'invalid-command'; echo $status

("Unknown command" error) which correctly returns 127.

A new status code,

STATUS_ILLEGAL_CMD = 123

is introduced - which is returned whenever the 'Illegal command name *'
message is printed.

This commit also adds a test which checks if valid commands return 0,
while commands with illegal name return status code 123.

Fixes #3606.

TODOs:

  • Changes to fish usage are reflected in user documenation/manpages.
  • Tests have been added
  • Decide if new status code STATUS_ILLEGAL_CMD=123 should really be added, or STATUS_UNKNOWN_COMMAND=127 should be reused (as the issue reporter suggested)

What do you think? Should STATUS_UNKNOWN_COMMAND be used instead? I don't have problems rewriting the commit to use it instead of new status code.

And please check the test. I'm not very experienced with C++ .

This commit fixes a bug which causes that

   fish -c ')'; echo $status

("Illegal command name" error) returns 0. This is inconsistent with
e.g. when trying to run non-existent command:

   fish -c 'invalid-command'; echo $status

("Unknown command" error) which correctly returns 127.

A new status code,

    STATUS_ILLEGAL_CMD = 123

is introduced - which is returned whenever the 'Illegal command name *'
message is printed.

This commit also adds a test which checks if valid commands return 0,
while commands with illegal name return status code 123.

Fixes fish-shell#3606.
@ridiculousfish
Copy link
Member

Thanks for the great contribution. The tests look outstanding!

I like the introduction of STATUS_ILLEGAL_CMD since that seems like a very distinct error from STATUS_UNKNOWN_CMD. The first is for syntactic errors, the second for commands that were not found.

@ridiculousfish ridiculousfish added this to the fish 2.5.0 milestone Dec 3, 2016
@ridiculousfish ridiculousfish added the release notes Something that is or should be mentioned in the release notes label Dec 3, 2016
@ridiculousfish ridiculousfish merged commit 254762f into fish-shell:master Dec 3, 2016
@ridiculousfish
Copy link
Member

Merged. Thank you!!

@ridiculousfish ridiculousfish added the bug Something that's not working as intended label Dec 3, 2016
@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 Something that's not working as intended release notes Something that is or should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fish -c ')' (invalid syntax) should exit with a non-zero status
2 participants