zsh: 'bad math expression: operator expected' when assigning to a variable named GID
@drashti0913▲ 0 net votes
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.