Shell snapshot enables set -o monitor and set -o onecmd in every Bash tool shell (grep "on" matches option names)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Search the shell snapshot generation for the shown set -o | grep "on" command and inspect how Bash options are recorded. Reproduce the behavior in a clean Bash using the commands in the issue, then change the state matching so only options whose state is on are written; verify that monitor and onecmd are absent when off.
Written by the indexing model from the issue text.
Description
Summary
The shell snapshot captures shell options with:
set -o | grep "on" | awk '{print "set -o " $1}' | head -n 1000 >> "$SNAPSHOT_FILE"
grep "on" is meant to keep options whose state is on, but it matches the substring anywhere in the line. Two option names contain "on": monitor and onecmd. Both are written to the snapshot as set -o monitor and set -o onecmd even when they are off, so every Bash tool shell runs with job control and onecmd enabled.
This appears to be the root cause of #47689 and #19057 (see also #17534 and #16231), which report set -o onecmd in snapshots on shells where it is off.
Reproduction
In a clean bash:
$ env -i bash --norc --noprofile -c 'set -o | grep -E "^(monitor|onecmd)\s"'
monitor off
onecmd off
$ env -i bash --norc --noprofile -c 'set -o | grep "on" | awk "{print \"set -o \" \$1}"'
set -o braceexpand
set -o hashall
set -o interactive-comments
set -o monitor
set -o onecmd
In Claude Code, ~/.claude/shell-snapshots/snapshot-bash-*.sh contains set -o monitor and set -o onecmd, and echo $- in a Bash tool call prints hmtBc (m is monitor, t is onecmd).
Effects
monitorin a non-interactive shell puts each background job in its own process group, and bash prints job-status lines such as[1]+ Done sleep 0.1into tool output.onecmd: the linked issues report Bash tool calls returning no output.
Suggested fix
Match the state column instead of the substring:
set -o | awk '$2 == "on" {print "set -o " $1}' | head -n 1000 >> "$SNAPSHOT_FILE"
With this change, the clean-shell output above contains only braceexpand, hashall, and interactive-comments.
Environment
- Claude Code 2.1.283
- Dominant language
- TypeScript
- Stars
- 153k
- Forks
- 26.7k
- Avg merge
- 22h 37m
- Merged PRs (30d)
- 19
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from anthropics/claude-code
-
area:agent-view area:tui bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
anthropics/claude-code#104558 ·
Maintainers usually reply within 1 day
-
area:core enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anthropics/claude-code#104510 ·
Maintainers usually reply within 1 day
-
area:ide bug platform:intellij
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
anthropics/claude-code#104508 ·
Maintainers usually reply within 1 day
-
area:ide bug has repro platform:macos platform:vscode
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
anthropics/claude-code#104480 ·
Maintainers usually reply within 1 day
-
area:agents area:model bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
anthropics/claude-code#104430 ·
Maintainers usually reply within 1 day
All issues in anthropics/claude-code
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
db-ux-design-system/core-web#8613 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
foxglove/mcap#1907 · 1 comment ·
Maintainers usually reply within 1 day
-
bug internal-plugin pr-welcome upstream
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dsh-tauri-desk/deepseek-harness-desktop#1225 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
unjs/unhead#1027 · 1 reaction ·
Maintainers usually reply within 1 day