1
0

found bug with stris_posix regex, fixed fdivide_posix

This commit is contained in:
Deven Blake 2021-06-17 15:22:19 -04:00
parent 5ed6294f67
commit bb9777ef27

View File

@ -86,7 +86,7 @@ printbar() {
fdivide_posix() {
[ -n "$2" ] && [ -n "$1" ] && [ -z "$3" ] \
|| return 1
printf "%b" "$(($2/$1))"
printf "%b\n" "$(($1/$2))"
return
}
@ -101,6 +101,7 @@ gt_posix() {
}
# limited POSIX shell version of stris
# BROKEN REGEX. MUSTFIX.
stris_posix() {
[ -n "$2" ] || return 1
case "$1" in
@ -122,22 +123,33 @@ stris_posix() {
return
}
if [ -n "$POSIXLY_CORRECT" ]; then
alias fdivide="fdivide_posix"
alias gt="gt_posix"
alias stris="stris_posix"
fi
# check to make sure we have non-standard utilities
[ -n "$POSIXLY_CORRECT" ] || ! which fdivide >/dev/null 2>&1 \
&& alias fdivide="fdivide_posix" \
|| true
[ -n "$POSIXLY_CORRECT" ] || ! which gt >/dev/null 2>&1 \
&& alias gt="gt_posix" \
|| true
[ -n "$POSIXLY_CORRECT" ] || ! which stris >/dev/null 2>&1 \
&& alias stris="stris_posix" \
|| true
# check to make sure customizeable vars are in proper format
[ -n "$INTERVAL" ] && stris int "$INTERVAL" \
|| INTERVAL=1 \
&& true
|| INTERVAL=1
[ -n "$CPU_TEMP_SCALE" ] && stris int "$CPU_TEMP_SCALE" \
&& gt "$CPU_TEMP_SCALE" 0 \
|| CPU_TEMP_SCALE=1 \
&& true
|| CPU_TEMP_SCALE=1
[ -n "$CPU_TEMP_FILES" ] \
|| alias get_cpu_temp="printf '[no temperature files specified]\n'" \
&& true
|| alias get_cpu_temp="printf '[no temperature files specified]\n'"
# main loop
while true; do
printbar