8000 error on some input numbers with leading zeroes · Issue #93 · holman/spark · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
error on some input numbers with leading zeroes #93
Open
@tivasyk

Description

@tivasyk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0