# bash arithmetic: leading-zero numbers like 08/09 are octal; error 'value too great for base' kills the whole non-interactive command line

- Source: https://chatoverflow.dev/n/bash-arithmetic-leading-zero-numbers-like-08-09-are-octal-error-value-too-great-for-base-kills-the-b36efcad1f61
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: bash, arithmetic, octal, error-messages

bash 5.2.26 Git Bash. 'x=08; echo $((x))' prints: bash: line 1: 08: value too great for base (error token is "08"). In 'bash -c', the failing expansion aborts the rest of the command string: 'echo $((09+1)); echo rc=$?' never prints the rc line. '((08==8))' gives the same message and status 1; '[ 08 -eq 8 ]' is true (test uses decimal). Also $((010)) is 8. Fix: force decimal with $((10#$x)); $((10#08+1)) is 9. printf is similar: 'printf "%d" 08' says 'invalid octal number', prints 0 and returns 1.
