Skip to content

Conversation

@MSch
Copy link
Contributor

@MSch MSch commented Jul 26, 2025

Add null check for DIRSTACKSIZE variable before numeric comparison to prevent shell errors when Claude Code unsets the environment variable.

🤖 Generated with Claude Code

Add null check for DIRSTACKSIZE variable before numeric comparison
to prevent shell errors when Claude Code unsets the environment variable.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@zeha
Copy link
Member

zeha commented Jul 26, 2025

hi @MSch, just wondering: when does Claude Code unset DIRSTACKSIZE?

@msch-nutrient
Copy link

msch-nutrient commented Jul 26, 2025

@zeha I wish I knew. I've been observing chpwd:2: bad math expression: operand expected at `<= 0 ' from time to time when it's invoking the Bash tool (which actually runs $SHELL) and haven't been able to track down why exactly it happens. You could argue that in the age of vibe coding it's easier to add more slop / defensive coding everywhere to make up for whatever the AI may or may not do.

> Is the DIRSTACKSIZE env var set?

⏺ Bash(echo $DIRSTACKSIZE)
  ⎿  (No content)

⏺ No, the DIRSTACKSIZE environment variable is not set (empty value).

> which env vars are set

⏺ I'll check the environment variables that are currently set.

⏺ Bash(env | sort)
  ⎿  ANDROID_HOME=/usr/local/opt/android-sdk    
     ANDROID_NDK_HOME=/usr/local/opt/android-ndk
     BUNDLER_EDITOR=subl -n
     … +50 lines (ctrl+r to expand)

⏺ The key environment variables set are:

  - CLAUDECODE=1 - Indicates Claude Code CLI is running
  - CLAUDE_CODE_ENTRYPOINT=cli - Entry point mode
  - PATH - Includes various development tools and binaries
  - HOMEBREW_NO_AUTO_UPDATE=1 - Prevents Homebrew auto-updates
  - PNPM_HOME - pnpm package manager location
  - ANDROID_HOME/ANDROID_NDK_HOME - Android development paths
  - GOPATH - Go development workspace
  - Standard shell variables (HOME, USER, SHELL, PWD, etc.)

And yet:

% echo $DIRSTACKSIZE
20

@zeha zeha merged commit 6e56156 into grml:master Jul 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants