Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on some input numbers with leading zeroes #93

Open
tivasyk opened this issue Feb 19, 2017 · 0 comments
Open

error on some input numbers with leading zeroes #93

tivasyk opened this issue Feb 19, 2017 · 0 comments

Comments

@tivasyk
Copy link

tivasyk commented Feb 19, 2017

when feeding spark with numbers that have leading zeroes bash will eventually report an error when encountering numbers with 8 and 9 (e.g. 08, 09 etc) because bash automatically considers zero-leaded numbers as octals.

possible solution: strip leading zeroes. i have modified the spark() function in my testing spark fork:

    n=${n%%.*}
    # These 3 lines strip leading zeroes and fix error parsing octal-like numbers (008 etc) / tivasyk
    shopt -s extglob
    n=${n##+(0)}
    shopt -u extglob
    # Fix empty n if it was 0
    if [[ $n -eq "" ]]; then
      n=0
    fi

it works, sorry for lame code.

p.s. great script! love it absolutely. i had to add scaling option (e.g. spark -s 100 ) to do things like cpu load gauges for conky etc. to be able to represent percentage data (0..100) in a meaningfull way.

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

No branches or pull requests

1 participant