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 a '-' prefixed in `argv[0]`,
thus breaking `stderred`'s early return on `bash` encounter. This leads
to normal text being always red.

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

Fixes ku1ik#52
  • Loading branch information
alex-thiessen-for-siemens committed Jan 3, 2019
1 parent 399e3b1 commit c8f1f8c
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)) 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 c8f1f8c

Please sign in to comment.