SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


fixscriptvaluetoogreatforbase
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

fixscriptvaluetoogreatforbase [2013/04/21 10:08] (current)
sjoerd created
Line 1: Line 1:
 += Fix: Script: Value Too Great For Base =
  
 +<​code>​
 +./​script.sh:​ line 101: [[: 09: value too great for base (error token is "​09"​)
 +</​code>​
 +
 +The error occurs when you have a integer value that start with a "​0"​ (zero). Bash will interpret that as an octal, which means 08 and 09 are invalid. I got the error by setting the hour in an variable and making an comparison on it:
 +<​code>​
 +hour=`date +%H`
 +</​code>​
 +You can force bash to read the number as a decimal by putting "​10#"​ in front of it:
 +<​code>​
 +hour="​10#​`date +%H`"
 +</​code>​
 +That fixed it.
 +
 +{{tag>​fix scripts}}
fixscriptvaluetoogreatforbase.txt ยท Last modified: 2013/04/21 10:08 by sjoerd