[BUG] shopt commands run in zsh

Resolved 💬 8 comments Opened Dec 6, 2025 by zzxyz Closed Feb 14, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The Problem:

  • Claude Code is attempting to run shopt (a bash builtin command) somewhere in its internal shell initialization

process

  • Since your shell is zsh, shopt doesn't exist, causing the "command not found" error before every command
  • This isn't coming from your config files - it appears to be internal to Claude Code itself

What Should Happen?

no shopt calls in non-bash shells

Error Messages/Logs

Here's CC trying to debug the problem of the shopt call.  You can see both its debug steps and the problem.  ("command not found") 

my .zshrc has a command not found handler that starts like so:
function command_not_found_handler {
    local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m'
    printf 'zsh: command not found: %s\n' "$1"

● Bash(typeset -f | grep -A 5 "precmd\|preexec" | head -30)
  ⎿  zsh: command not found: shopt
        hooktypes=(chpwd precmd preexec periodic zshaddhistory zshexit zsh_directory_name)
        local usage="Usage: add-zsh-hook hook function\nValid hooks are:\n  $hooktypes"
     … +4 lines (ctrl+o to expand)

● Bash(echo "${precmd_functions[@]}")
  ⎿  zsh: command not found: shopt

● Bash(echo "${preexec_functions[@]}")
  ⎿  zsh: command not found: shopt

● Read(.bash_profile)
  ⎿  Read 6 lines

● Bash(grep -l shopt ~/.*rc ~/.* 2>/dev/null)
  ⎿  Error: Exit code 2
     zsh: command not found: shopt
     /home/aubrey/.histfile
     /home/aubrey/.viminfo

Steps to Reproduce

Install zsh, make zsh the default shell for the user (I think it was just chsh), have visible output when unsupported commands are run.
Do anything that causes CC to run "bash" commands

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.55

Claude Code Version

HMSLively:~/claudesession£ claude --version 2.0.60 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Windows Terminal

Additional Information

Arch Linux under WSL2 (I think wsl is irrelevant here)
I didn't see this under 2.0.55 and my version jumped to 2.0.60 from there, so I have not tested intermittent versions (at least not under arch).

I've done my best (and so has Claude) to make sure there's nothing in my environment causing this, but I'm definitely unaware of any changes and claude couldn't find the issue.

full handler if it's useful:

function command_not_found_handler {
    local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m'
    printf 'zsh: command not found: %s\n' "$1"
    local entries=(
        ${(f)"$(/usr/bin/pacman -F --machinereadable -- "/usr/bin/$1")"}
    )
    if (( ${#entries[@]} ))
    then
        printf "${bright}$1${reset} may be found in the following packages:\n"
        local pkg
        for entry in "${entries[@]}"
        do
            # (repo package version file)
            local fields=(
                ${(0)entry}
            )
            if [[ "$pkg" != "${fields[2]}" ]]
            then
                printf "${purple}%s/${bright}%s ${green}%s${reset}\n" "${fields[1]}" "${fields[2]}" "${fields[3]}"
            fi
            printf '    /%s\n' "${fields[4]}"
            pkg="${fields[2]}"
        done
    fi
    return 127
}

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗