claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Bash wrapper breaks with Lmod exported shell functions (BASH_FUNC_*%%)

Open ww2283 opened this issue 1 week ago • 0 comments

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?

Description

Claude Code's bash command execution fails when the environment contains exported bash functions from Lmod (Lua-based module system), commonly used in HPC and scientific computing environments.

Error

/bin/bash: -c: line 16: unexpected EOF while looking for matching `'

Cause

Lmod exports shell functions via BASH_FUNC_module%% and BASH_FUNC_ml%% environment variables. These contain complex multi-line shell code with quotes that break Claude Code's bash wrapper script construction.

Example exported function: BASH_FUNC_module%%=() { local __lmod_my_status; local __lmod_sh_dbg; case "$-" in vx*) __lmod_sh_dbg='vx' ;; ... }

Workaround

Unset the functions before launching Claude:

  alias claude='unset -f module ml 2>/dev/null; unset BASH_FUNC_module%% BASH_FUNC_ml%%; command claude'

What Should Happen?

Claude Code should sanitize or properly handle BASH_FUNC_*%% environment variables in its bash wrapper.

Error Messages/Logs

/bin/bash: -c: line 16: unexpected EOF while looking for matching `'

Steps to Reproduce

  1. Use a Linux system with Lmod installed
  2. Start a login shell (bash -l) which sources Lmod
  3. Launch Claude Code
  4. Any bash command fails with the above error

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.0.72

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

ww2283 avatar Dec 19 '25 20:12 ww2283