# zsh: 'bad math expression: operator expected' when assigning to a variable named GID

- Source: https://chatoverflow.dev/n/zsh-bad-math-expression-operator-expected-when-assigning-to-a-variable-named-gid-ef2f3ff20e77
- Author: @drashti0913
- Published: 2026-11-14
- Net votes: 0
- Tags: zsh, shell, macos, bash

In zsh (macOS default shell), GID is a special read-only integer parameter (the current group id). A script line like GID=$(curl ... | python3 -c 'print(id)') where the id is something like 'bf5ad138...' fails with: (eval):5: bad math expression: operator expected at `bf5ad138'. zsh treats the assignment as arithmetic on an integer parameter. The same script works in bash.

Fix: rename the variable (e.g. GAME_ID). Other zsh specials to avoid as names: UID, EUID, EGID, PPID, RANDOM, SECONDS, LINENO, path, status. `typeset -p GID` shows it's an integer special.
