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

nix search --json: Don’t fail for empty result set #3448

Closed
wants to merge 1 commit into from

Conversation

pmiddend
Copy link

I'm using nix search --json to generate a list of all the packages available for installation. I noticed that I cannot test this command for failure, because...it always fails.

Specifically, it always outputs "no results for the given search term(s)", even after outputting a huge list of packages, and it always results in an exit code of 1.

Is this intentional? I see two cases to handle here:

  1. The user doesn't provide a search string, so nix search or nix search --json. This is valid and even an example in the manpage. In this case, I think you never want to fail.
  2. The user provides a search string, and nothing is found. In this case, failing (and outputting a message on stderr) is good behavior when --json isn't provided. If it is, I think it's a matter of preference. I personally wouldn't let it fail. The script you're writing can process the JSON and check for emptiness.

Regarding the code: Since results is apparently not filled in json mode, testing it for emptiness doesn't make much sense. This PR only tests this in plain-text mode as a first fix to the problem.

@evils
Copy link
Member

evils commented Mar 25, 2020

duplicate of #2266 and #2657?

@pmiddend
Copy link
Author

Apparently. Sorry for that. Curious though, why does it take so long to merge this?

@pmiddend pmiddend closed this Mar 25, 2020
@Mic92
Copy link
Member

Mic92 commented May 6, 2020

Fixed in #3572 and #3570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants