Skip to content

gh auth status writes to stderr instead of stdout on success #7447

@david-induro

Description

@david-induro

Describe the bug

I noticed that trying to assign the output of gh auth status to a variable that the variable would never populate. I did some investigating and found that if I pipe stdout to a file, I get an empty file, and the output still logs to the console. If I log stderr to a file, I the output in a file and a silent console.
I've confirmed this happens on both PowerShell (on Windows) and Bash (in WSL2.)

Steps to reproduce the behavior

  1. Authenticate successfully with the gh cli, so that you see Logged in to github.com when calling gh auth status
  2. Run the command and pipe stdout to a file gh auth status 1> stdout.txt
  3. Observe command output in termial, and see no output in stdout.txt.
  4. Run the command and pipe stderr to a file gh auth status 2> stderr.txt
  5. Observe no output to console, but see output in stderr.txt

Expected vs actual behavior

Authentication status (both logged in, and logged out) should log through stdout. stderr should be reserved for issue with script execution.

Logging to stderr by default breaks the ability to script based on log out (searching for a permission string, in my case,) unless you know to look at stderr instead of stdout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions welcomepriority-2Affects more than a few users but doesn't prevent core functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions