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

Adds a `--quiet`/`-q` option for `command -s` #3591

Merged
merged 1 commit into from Nov 28, 2016

Conversation

@floam
Copy link
Member

floam commented Nov 27, 2016

Description

I think devnull'ing command -v program_name to check presence is a common
enough chore that a --quiet option which works like it does on type would be handy for writers of shell scripts. Simply mutes the output for checking the exit status.

command -qs foo should behave identically to command -s foo >/dev/null, command -v foo >/dev/null

Includes updated documentation.

@floam floam force-pushed the floam:command-quiet branch from 683aa43 to aa1f166 Nov 27, 2016
@faho
Copy link
Member

faho commented Nov 27, 2016

As I read this, this still accepts "-q" without "-s" as a noop.

Personally, I'm okay with that, but there might be reasons to error out - I think @krader1961 likes behavior like that.

@faho faho added the enhancement label Nov 27, 2016
@faho faho added this to the fish 2.5.0 milestone Nov 27, 2016
@floam
Copy link
Member Author

floam commented Nov 27, 2016

As I read this, this still accepts "-q" without "-s" as a noop.

No, that's an error and the help is printed.

edit: oops, I hit the close pull request instead of the green comment button.

@floam floam closed this Nov 27, 2016
@floam floam reopened this Nov 27, 2016
@floam
Copy link
Member Author

floam commented Nov 27, 2016

(command -q is an error, command -q commandname is also an error. )

This function here only does the argument handling aspect of the builtin, outside the parser, and it already was causing errors unless print_path is true.

I think devnull'ing this builtin to check presence is a common
enough chore that a --quiet option which works like it does on
`type` would be handy.
@floam floam force-pushed the floam:command-quiet branch from aa1f166 to b41b887 Nov 27, 2016
@floam floam merged commit 121109e into fish-shell:master Nov 28, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@faho faho added the release notes label Dec 2, 2016
elasticdog added a commit to elasticdog/dotfiles that referenced this pull request Feb 11, 2017
This was a new addition to provide a simple way of checking whether
a command exists in scripts.

See: fish-shell/fish-shell#3591
@faho faho mentioned this pull request Feb 14, 2017
1 of 2 tasks complete
@franciscolourenco
Copy link

franciscolourenco commented Feb 15, 2017

How does this compare to type -q?

@krader1961
Copy link
Contributor

krader1961 commented Feb 15, 2017

How does this compare to type -q?

Using command -qs some_command is more natural when you want to explicitly test if an external command (i.e., program) exists by that name in $PATH. Using type -q is appropriate if you just want to verify that a command of the given name exists whether it's a builtin, function, or external command.

@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.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.