Skip to content

Fix parent process detection in batpipe#96

Open
ebugusey wants to merge 1 commit intoeth-p:masterfrom
ebugusey:fix/batpipe/detect-parent-basename
Open

Fix parent process detection in batpipe#96
ebugusey wants to merge 1 commit intoeth-p:masterfrom
ebugusey:fix/batpipe/detect-parent-basename

Conversation

@ebugusey
Copy link

Less is called with a filename, and if we basename CMD of less we get a basename of a filename, not a less executable. I think it's just a type that basename was piped to cut, CMD should be cut'ed before processed by basename.

As parent_executable is only used by batpipe, we can just cut CMD and extract program name.

Less is called with a filename, and if we basename CMD of less we get
a basename of a filename, not a less executable. I think it's just
a type that basename was piped to cut, CMD should be cut'ed before
processed by basename.

As parent_executable is only used by batpipe, we can just cut CMD and
extract program name.
@nigelgbanks
Copy link

@ebugusey cheers for this!

markrustad added a commit to markrustad/bat-extras that referenced this pull request Jan 26, 2026
Fix batpipe failing to detect when running inside `less` on modern Linux
systems with procps-ng.

The issue was that `parent_executable()` returned the full command line
(e.g., "less /etc/passwd ") instead of just the program name. When
`basename` operated on this, it returned "passwd" instead of "less",
causing batpipe to disable color output.

Changes:
- Move `cut -d' ' -f1` into `parent_executable()` to extract just the
  program name before returning
- Remove now-redundant `cut` calls in batpipe.sh
- Fix gawk 5.x compatibility: change `printf $i" "` to `printf "%s ", $i`
  (GNU Awk 5.x requires format strings for printf)

Fixes eth-p#142
Incorporates fix from eth-p#96 with additional gawk compatibility fix.
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.

2 participants