fix(batpipe): parent process detection on Linux with procps-ng and gawk 5.x#145
Open
markrustad wants to merge 1 commit intoeth-p:masterfrom
Open
fix(batpipe): parent process detection on Linux with procps-ng and gawk 5.x#145markrustad wants to merge 1 commit intoeth-p:masterfrom
markrustad wants to merge 1 commit intoeth-p:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix batpipe failing to detect when running inside
lesson modern Linux systems with procps-ng (e.g., Fedora 42+).The Problem
On systems with modern procps-ng,
parent_executable()returns the full command line (e.g.,less /etc/passwd) instead of just the program name. Whenbasenameoperates on this, it returnspasswdinstead ofless, causing batpipe to incorrectly detect the parent process and disable color output.Additionally, GNU Awk 5.x is stricter about printf format strings, causing errors like:
Changes
cut -d' ' -f1intoparent_executable()to extract just the program namecutcalls (handled by proc.sh)printf $i" "toprintf "%s ", $iTesting
Tested on Fedora with:
Before fix:
After fix:
Related Issues
Compatibility
The
printf "%s ", $isyntax is POSIX-compliant and works on all awk implementations (gawk, mawk, nawk, busybox awk).