Skip to content

bc error with comma floating separate decimal on some différent local systems #1

@grangec

Description

@grangec

In exemple,
In a French system with a coma decimal separating sign, awk return number like this exemple : '31,0'
The bc command then return an error : '(standard_in) 1: syntax error'

a simple solution is to force the C local in 'get_avg_cpu_temperature' like this :

get_avg_cpu_temperature() {
temps=$(get_cpu_temperatures)
if [ -z "$temps" ]; then
echo ""
else
echo "$temps" | awk '{sum+=$1} END {if (NR>0) print sum/NR; else print ""}' | LC_ALL=C awk '{printf "%.1f", $0}'
fi
}

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