From bb9777ef27e4e4a68dd75796d02a908ad5c0aedc Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Thu, 17 Jun 2021 15:22:19 -0400 Subject: [PATCH] found bug with stris_posix regex, fixed fdivide_posix --- dotfiles-old/bin/data | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/dotfiles-old/bin/data b/dotfiles-old/bin/data index ee37fe4..e107f39 100755 --- a/dotfiles-old/bin/data +++ b/dotfiles-old/bin/data @@ -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