Skip to content

include pager stderr in --pager failure messages - #948

Open
c-tonneslan wants to merge 1 commit into
charmbracelet:masterfrom
c-tonneslan:fix/pager-error-include-stderr
Open

include pager stderr in --pager failure messages#948
c-tonneslan wants to merge 1 commit into
charmbracelet:masterfrom
c-tonneslan:fix/pager-error-include-stderr

Conversation

@c-tonneslan

Copy link
Copy Markdown

Closes #153.

When the pager command fails (e.g. `most` exits non-zero on input it doesn't like), the user just sees "Error: unable to run command: exit status 1" with no clue which pager failed or why — the pager's own stderr is dropped because `c.Stderr` is never assigned.

Capture stderr into a buffer, name the pager binary in the error, and append the pager's complaint when there is one. `PAGER=most glow -p` now reports something like:

```
pager "most" failed: exit status 1: most: Cannot ...
```

instead of a bare "exit status 1". Same shape for the not-installed case:

```
pager "most" failed: exec: "most": executable file not found in $PATH
```

Reproduced both locally (the second one against my machine which doesn't have most). Full test suite passes.

When the pager command fails (e.g. `most` exits non-zero on input
it doesn't like), the user just sees "Error: unable to run command:
exit status 1" with no clue which pager failed or why. The pager's
own stderr is dropped on the floor because we never assigned
c.Stderr.

Capture stderr into a buffer, name the pager binary in the error,
and append the pager's complaint when there is one. So `PAGER=most
glow -p` now reports something like

	pager "most" failed: exit status 1: most: Cannot ...

instead of a bare "exit status 1" (charmbracelet#153).

Closes charmbracelet#153

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
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.

exit status 1 when used with most PAGER

1 participant