You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logging.sh could emit Bash internals errors when the original failure came from an exported/external function. Instead of logging the failure cleanly, the fatal path could recurse into pop_var_context: head of shell_variables not a function context.
Root cause
fatal() cleaned up child jobs with a jobs -p | xargs kill pipeline.
In the exported-function error path, that cleanup command could itself trip Bash’s function-context handling and mask the original failure.
Change
Replaced the cleanup pipeline with guarded, Bash-native PID collection and termination.
Child PIDs are read into an array first; kill is only invoked when the array is non-empty.
Cleanup failures are explicitly ignored so logging preserves the original error path.
Behavior
Failures originating from exported functions now log normally instead of crashing inside Bash internals.
Existing child-process cleanup behavior is preserved for normal fatal exits.
CopilotAI
changed the title
[WIP] Fix logging failure with externally defined bash functions
Handle exported-function failures without crashing logging cleanup
Apr 8, 2026
@copilot how does this actually fix the problem the user reported? this seems like an unrelated change? or am I misunderstanding?
Yes — I verified the failure is already on the existing ERR -> log_quit -> fatal path, and the extra pop_var_context comes from fatal()'s child-cleanup line, not from the exported function body itself. Using the same exported-function repro against HEAD~1 vs 0ceef7b: HEAD~1 logs [FATAL] environment:0 external_fail() 1 and then hits pop_var_context, while 0ceef7b logs the same fatal message without the Bash internal error. So the change is related because it removes the crashing step in the logging path that only shows up when the original failure came from an exported environment function.
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
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.
logging.shcould emit Bash internals errors when the original failure came from an exported/external function. Instead of logging the failure cleanly, the fatal path could recurse intopop_var_context: head of shell_variables not a function context.Root cause
fatal()cleaned up child jobs with ajobs -p | xargs killpipeline.Change
killis only invoked when the array is non-empty.Behavior