-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Describe the bug
GitHub CLI command gh repo set-default --view returns exit code 0 and prints error to stdout instead of stderr when the default repo isn't set.
This breaks Unix command line standard behaviour and makes it hard to detect and script around error handling and recovery.
$ gh --version
gh version 2.42.1 (2024-01-15)
https://github.com/cli/cli/releases/tag/v2.42.1
I've tried with the newer version too, same result:
$ gh --version
gh version 2.53.0 (2024-07-17)
https://github.com/cli/cli/releases/tag/v2.53.0
Steps to reproduce the behavior
In a repo clone, especially a forked repo:
gh repo set-default --view
echo $?outputs:
no default repository has been set; use `gh repo set-default` to select one
0
You can see it outputs to stdout in place where the repo name would be expected. This will easily break the scripts of people expecting standard unix command line behaviour:
gh repo set-default --view 2>/dev/nulloutputs to stdout instead of stderr:
no default repository has been set; use `gh repo set-default` to select one
although in a pipe this actually returns no output which is slightly easier to catch in script than testing for an error message which might change:
gh repo set-default --view | catreturns no output:
Expected vs actual behavior
Expected it to exit code 1 if throwing an error such as no default repository has been set
Expected it to print the error to stderr instead of stdout.