Repository navigation
gh api not using $PAGER correctly #9017
Description
Activity
Uh oh! Any chance you could capture this in a screen recording to help me better understand what you're seeing! It would be very interesting to know if this reproduced in
v2.47.0,v2.46.0andv2.45.0if you're up for doing some spelunking! How often does it reproduce?- addedgh-apirelating to the gh api commandrelating to the gh api command
on Apr 28, 2024 Any chance you could capture this in a screen recording to help me better understand what you're seeing!
Here are two asciinema recordings; the first one involves more than a screenful of output, while the second involves less than a screenful. In both cases, all I did inside
lesswas pressg(which should have taken me to the top of the output but instead cleared the output) and thenqto quit.It would be very interesting to know if this reproduced in
v2.47.0,v2.46.0andv2.45.0if you're up for doing some spelunking!I downloaded the macOS amd64 release assets for each of those versions from the Releases page, and none of them exhibited the bug. Just to be sure this wasn't Homebrew's fault, I also downloaded the 2.48.0 asset from the Releases page, and it still has the buggy behavior.
How often does it reproduce?
Every time I've used
gh apifor the past month or so (assumingPAGERandLESSare set and there's no output redirection etc.)Reacted by William Martin@williammartin I'm currently debugging this and trying both v2.47.0 and v2.48.0 to see what's causing this. So far, everything is the same between the two (for this specific scenario where the newly introduced
jsonArrayWriteris not used). Will update you soon.@williammartin I just submitted #9020 to fix this. The change that caused this in v2.48.0, was the calling of
StartPagermethod at a later stage.And sorry because it's not yet marked as
help-wanted. I thought this way it's easier for you to see the changes.


OS: macOS Sonoma 14.4.1
gh version: 2.48.0 (installed via Homebrew)
I have the environment variables
PAGER=/usr/bin/lessandLESS=-iRS(but notGH_PAGER) set in my shell. Starting sometime maybe in the last month, whenever I rungh apiwithout any output redirection, the program will startlessto show the output, but the screen will show the last lines of the output rather than the start of the output, and if I then press any key, the output disappears, to be replaced by a tilde on each line (which is howlessdisplays empty input). I think this problem is caused by mixing up stdout and stderr, but I'm unable to come up with an MVCE.If I unset
PAGER,gh apiwill output to stdout correctly. If I unsetLESSinstead,gh apistill outputs to stdout without invokingless.