1234567891011121314151617181920212223242526272829 |
- #!/usr/bin/env bash
- # grugly@sdf
- # Converts things to other things.
- source '../say.sh'
- msg='Usage: !convert <f2c|c2f> number'
- src="$2"
- con="$3"
- inp="$4"
- case "$con" in
- 'f2c')
- if [[ "$inp" =~ [0-9]$ ]]; then
- msg="$(echo "scale=2;(5/9)*($inp-32)"|bc)°C"
- fi
- ;;
- 'c2f')
- if [[ "$inp" =~ [0-9]$ ]]; then
- msg="$(echo "scale=2;((9/5)*$inp)+32"|bc)°F"
- fi
- ;;
- esac
- say "$src" "$msg"
|