{"version":"2.1.328","anchor":"sandbox-bash-started-with-p-shell-glob-options","canonical_anchor":"sandbox-bash-started-with-p-shell-glob-options","heading":"Sandboxed Bash commands start under bash -p with stored variables cleared","tier":"internal","area":"Sandbox","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.328\/e\/sandbox-bash-started-with-p-shell-glob-options","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.328","markdown":"### Sandboxed Bash commands start under bash -p with stored variables cleared\n\nSandboxed commands now run as bash -p and clear BASH_ENV, CDPATH and PS4, unless your settings or \/env set BASH_ENV, SHELLOPTS or BASHOPTS\n\n**Unclear.** Whether this applies to the sandbox on every platform is not settled.\n\n**What**\n\nThe sandbox is a restricted environment Claude Code can run shell commands in. When Claude Code builds a sandboxed command of the form `<bash|sh> -c cmd`, it now rewrites it to start bash with `-p`, a mode in which bash reads no start-up file:\n\n- The command becomes `bash -p -c 'set +p; unset BASH_ENV; unset CDPATH; PS4=...; cmd'`, so `BASH_ENV` and `CDPATH` are removed and `PS4` is reset before your command runs.\n\n- This is skipped, and the command is left as built, if a settings file or `\/env` supplies a non-empty `BASH_ENV`, `SHELLOPTS` or `BASHOPTS`.\n\n- An accompanying explanation is given for each case, for example \"bash is started under -p, so it takes no start-up file, functions or shell options from variables stored for the sandbox account.\"\n\n- The shell set-up snippet also gains `NO_EQUALS` for zsh, and is used when both shells match.\n\nBefore, the command was passed on exactly as built.\n\n**Why**\n\nStart-up files, shell functions and shell options stored for the sandbox account, possibly by another project, can no longer leak into a sandboxed command. If you rely on `BASH_ENV`, `SHELLOPTS` or `BASHOPTS`, setting them in settings or `\/env` keeps the old behaviour.\n\n- Area: Sandbox\n- Tier: Under the hood\n- Useful: 2\/5\n- Signal: 1\/5\n- Scope: individual\n- Heads-up: no"}