fix(init): stop plugin-sourced shell opts leaking into the caller's shell - #44
Open
alfred-agent-broker[bot] wants to merge 3 commits into
Open
alfred-agent-broker[bot] wants to merge 3 commits into
alfred-agent-broker[bot] wants to merge 3 commits into
Conversation
Any sourced plugin script that changes u/e/pipefail (e.g. a file-scope
`set -u`) leaked those options into whatever shell sourced init.bash --
confirmed via %dante/run-recorder's session-recorder.sh, which broke
bash completions in the operator's interactive shell ("ZYPPER_CMDLIST:
unbound variable" from zypper's completion, and every shy completion
affected the same way) once nounset leaked out of a sourced entry.sh.
Add _shy_safe_source: sources a file, then restores u/e/pipefail to
whatever they were immediately before the source if the sourced file
changed them. Used in place of bare `source` in both
_shy_source_flat and _shy_source_installed_scripts, so this protects
against every current AND future plugin, not just the one that
triggered this fix (which is fixed at its own source in a companion
%dante/run-recorder change).
Board: 20a1e3d2.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mr-RedHat-fb
self-requested a review
July 21, 2026 13:04
Mr-RedHat-fb
requested changes
Jul 21, 2026
| # init.bash, breaking unrelated things (e.g. bash completions tripping over | ||
| # `set -u` on an unset variable). Belt-and-suspenders: protects against every | ||
| # current AND future plugin, on top of any per-plugin fix. | ||
| _shy_safe_source() { |
Contributor
There was a problem hiding this comment.
| # init.bash, breaking unrelated things (e.g. bash completions tripping over | ||
| # `set -u` on an unset variable). Belt-and-suspenders: protects against every | ||
| # current AND future plugin, on top of any per-plugin fix. | ||
| _shy_safe_source() { |
Contributor
There was a problem hiding this comment.
|
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
%dante/run-recorderplugin's file-scopeset -uleakednounset into the operator's interactive shell on every fresh shell (shy's
init.bashsources every installed script'sentry.shdirectly into thecurrent shell, not a subprocess). Symptom: zypper's bash completion errored
ZYPPER_CMDLIST: unbound variable, and every shy completion was affected._shy_safe_source(new helper ininit/init.bash/internal/cmd/init.bash)saves
$-before eachsourcecall and restores u/e/pipefail afterward ifthe sourced file changed them. Used in
_shy_source_flatand_shy_source_installed_scriptsin place of baresource— this protectsagainst every current AND future plugin, not just the one that triggered
this bug.
%dante/run-recorderplugin itself is fixed at its own source in acompanion
dante(Forgejo) repo PR, scopingset -uper-function vialocal -instead of file scope.Test plan
bash -c 'set +u; source init/init.bash >/dev/null 2>&1; [[ $- == *u* ]] && echo LEAK || echo CLEAN'→ CLEANsource init.bashstill succeeds;shy --helpstill worksrr-session-init/rr-status)still runs correctly with strict mode active inside the function
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com