Skip to content

Commit

Permalink
Fix tmux text being always red
Browse files Browse the repository at this point in the history
`tmux` (https://github.com/tmux/tmux/wiki) is a terminal multiplexer,
like `screen`. It spawns its terminals with `argv[0]` prefixed with a
'-', thus breaking `stderred`'s early return on `bash` encounter. This
leads to normal text being always red.

When `PROGRAM_NAME` matches the '-%s' format pattern, treat it as a
shell and return early.

Refer to https://github.com/tmux/tmux/blob/c9d482ab489d5d57d481858091608ee1b32e46ab/window.c#L993
and to tmux/tmux@22d1b94.

Fixes #52
  • Loading branch information
alex-thiessen-for-siemens committed Jan 3, 2022
1 parent b2238f7 commit 18689a0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/stderred.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ bool is_valid_env = false;

__attribute__((constructor, visibility ("hidden"))) void init() {
if (!strcmp("bash", PROGRAM_NAME)) return;
/* "tmux" spawns subshells with argv[0] prefixed with a '-', e.g. "-bash" */
if (PROGRAM_NAME && PROGRAM_NAME[0] == '-' && PROGRAM_NAME[1] != '\0') return;
if (!isatty(STDERR_FILENO)) return;

char *blacklist;
Expand Down

0 comments on commit 18689a0

Please sign in to comment.