Repository navigation
Report the submitted line in bash when the profile makes PROMPT_COMMAND an array - #1391
Merged
Merged
Conversation
systemd's 80-systemd-osc-context.sh, sourced from /etc/profile on Ubuntu 26.04, turns PROMPT_COMMAND into an array and appends its own hook. The bash integration captured and replaced only element 0, so on bash 5.1+ the hook ran after ours re-armed the DEBUG trap and every line reported the hook's name as its command. Fold every element into the user's hook and unset the array before installing ours.
Deploying mouseterm with
|
| Latest commit: |
ceb602e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fe96af06.mouseterm.pages.dev |
| Branch Preview URL: | https://fix-bash-array-prompt-comman.mouseterm.pages.dev |
This was referenced Oct 27, 2026
Joining the elements into one eval'd string handed each later element the status of the one before it, while bash 5.1+ gives every element the command's $?. A legacy `PROMPT_COMMAND=...` assigns element 0, so systemd's OSC 3008 hook reported every command as a success. Keep the elements as an array and set $? before each, through a function return instead of a fork. The test now uses systemd's own lines plus a legacy assignment, and checks the status the appended hook sees. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
On a system whose
/etc/profilesources systemd's80-systemd-osc-context.sh, such as Ubuntu 26.04, the bash integration reported every command line as__systemd_osc_context_precmdline. With this fix,Ecarries the submitted line again and systemd's hook still runs once per prompt.Cause. systemd's script makes
PROMPT_COMMANDan array and appends its hook.shellIntegration.bashcaptured"$PROMPT_COMMAND", which is element 0 only, then assignedPROMPT_COMMAND='__dormouse_633_prompt', which also replaces element 0 only. bash 5.1+ runs every element, so systemd's hook ran after__dormouse_633_promptre-armed the DEBUG trap and was reported as the next command. The line the user actually submitted got noE/C. On bash 5.1+, the integration now folds every element into the preserved user hook and unsets the array before installing its own. Older bash runs only element 0, and its behavior is unchanged.How this surfaced. #1390's
Build & Testjob ran on theubuntu-26.04image and failedbash: E is the whole submitted line…withbash reported ["__systemd_osc_context_precmdline"] for "true". Main's last green run usedubuntu-24.04.ci.ymlruns onubuntu-latest, so main's CI will go red the same way as runners move to 26.04.Verification. A new test in
standalone/sidecar/shell-integration.test.jsgives the PTY bash a~/.profilethat builds an arrayPROMPT_COMMANDthe way systemd does. It checks thatEis the submitted line and that the profile's hook still runs once per prompt. Without the fix it fails withbash reported ["__sfx_ran"] for "true". I also ran it locally (bash 5.2.21) with systemd's real script sourced from the profile: it passes with the fix and fails without it. The existing bash and zsh integration tests still pass.