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

Merged
merged 1 commit into from Nov 28, 2016

Conversation

Projects
None yet
4 participants
@floam
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.

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Nov 27, 2016

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@floam

floam Nov 27, 2016

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@floam

floam Nov 27, 2016

Member

(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.

Member

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.

Adds a `--quiet`/`-q` option for `command -s`
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 merged commit 121109e into fish-shell:master Nov 28, 2016

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

Use --quiet option for `command -s` tests
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 referenced this pull request Feb 14, 2017

Closed

Occasional `command: Unknown option “-q”` #3851

1 of 2 tasks complete
@franciscolourenco

This comment has been minimized.

Show comment
Hide comment
@franciscolourenco

franciscolourenco Feb 15, 2017

How does this compare to type -q?

How does this compare to type -q?

@krader1961

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Feb 15, 2017

Contributor

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment