From 27a38dd34af2e035eb0d37ce2f27f169763c3538 Mon Sep 17 00:00:00 2001 From: krebs Date: Fri, 9 Sep 2011 20:35:04 -0400 Subject: //noise /temp: fix inside-temperature bug --- noise/modules/temp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'noise/modules/temp') diff --git a/noise/modules/temp b/noise/modules/temp index 2f1dfcef..3c364acd 100755 --- a/noise/modules/temp +++ b/noise/modules/temp @@ -1,33 +1,40 @@ #! /bin/bash +temper=/krebs/temper/temper + main() { case "$1" in (--help) echo "report temperature in K, °C, °R, or °F." + exit ;; (-C|--celsius) - espeak_inside `inside_temp 'x - 273.15'` Grad Zelsius - espeak_outside `outside_temp 'x - 273.15'` Grad Zelsius + unit='Grad Zelsius' + formula='x - 273.15' ;; (-F|--fahrenheit) - espeak_inside `inside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit - espeak_outside `outside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit + unit='Grad Fahrenheit' + formula='x * 9/5 - 459.67' ;; (-R|--rankine) - espeak_inside `inside_temp 'x * 9/5'` Grad Renkin - espeak_outside `outside_temp 'x * 9/5'` Grad Renkin + unit='Grad Renkin' + formula='x * 9/5' ;; (-K|--kelvin|*) - espeak_inside `inside_temp` Kelvin - espeak_outside `outside_temp` Kelvin + unit='Kelvin' + formula=x ;; esac + if test -f $temper -a -x $temper; then + espeak_inside `inside_temp "$formula"` $unit + fi + espeak_outside `outside_temp "$formula"` $unit } ## temp [] ## Echo temperature in K. If formula is given then return that result instead. inside_temp() { - echo "scale=2; x=`/krebs/temper/temper` + 273.15; ${1-x}" | bc + echo "scale=2; x=`$temper` + 273.15; ${1-x}" | bc } outside_temp() { -- cgit v1.2.3 From 9c9e9809e61e5e6a45c5f5babd0fef17cdc1d33d Mon Sep 17 00:00:00 2001 From: krebs Date: Fri, 9 Sep 2011 21:29:15 -0400 Subject: //noise /temp: compress space --- noise/modules/temp | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'noise/modules/temp') diff --git a/noise/modules/temp b/noise/modules/temp index 3c364acd..a11c3720 100755 --- a/noise/modules/temp +++ b/noise/modules/temp @@ -3,26 +3,18 @@ temper=/krebs/temper/temper main() { - case "$1" in + case "${1--K}" in (--help) echo "report temperature in K, °C, °R, or °F." exit ;; - (-C|--celsius) - unit='Grad Zelsius' - formula='x - 273.15' - ;; - (-F|--fahrenheit) - unit='Grad Fahrenheit' - formula='x * 9/5 - 459.67' - ;; - (-R|--rankine) - unit='Grad Renkin' - formula='x * 9/5' - ;; - (-K|--kelvin|*) - unit='Kelvin' - formula=x + (-C|--celsius) unit='Grad Zelsius' ; formula='x - 273.15' ;; + (-F|--fahrenheit) unit='Grad Fahrenheit'; formula='x * 9/5 - 459.67' ;; + (-R|--rankine) unit='Grad Renkin' ; formula='x * 9/5' ;; + (-K|--kelvin) unit='Kelvin' ; formula='x' ;; + (*) + echo 'Error 1: you are made of stupid!' + exit 23 ;; esac if test -f $temper -a -x $temper; then @@ -43,13 +35,8 @@ outside_temp() { ` + 273.15; ${1-x}" | bc } -espeak_inside() { - echo Die Krebs-tempera-tur beträgt $@ | to_espeak -} - -espeak_outside() { - echo Die Außen-tempera-tur beträgt $@ | to_espeak -} +espeak_inside() { echo Die Krebs-tempera-tur beträgt $@ | to_espeak; } +espeak_outside() { echo Die Außen-tempera-tur beträgt $@ | to_espeak; } to_espeak() { sed ' -- cgit v1.2.3