Compare commits
2 Commits
ef48cc5cb4
...
74b7c0211a
Author | SHA1 | Date |
---|---|---|
ida schmidt | 74b7c0211a | |
ida schmidt | ac16a43f44 |
44
pizza.sh
44
pizza.sh
|
@ -1,9 +1,31 @@
|
|||
#!/usr/bin/env bash
|
||||
FSI=2.12206590789 # grams of Flour per Square Inch of pan
|
||||
|
||||
FSI=2.12206590789 # grams of flour per square inch of pan
|
||||
function pizzahelp {
|
||||
echo "Pizza Calculator: The pizza script you never asked for"
|
||||
echo
|
||||
echo "Usage: ./pizza.sh [-h] [-f] [<flour weight>g|<pan diameter>(in|inch|\")]"
|
||||
echo "Options:"
|
||||
echo " -h Print this help"
|
||||
echo " -f <N> Set flour per square inch"
|
||||
echo
|
||||
}
|
||||
|
||||
while getopts ":hf:" option; do
|
||||
case $option in
|
||||
h)
|
||||
pizzahelp
|
||||
exit;;
|
||||
f)
|
||||
FSI=$OPTARG
|
||||
shift 2;;
|
||||
\?)
|
||||
echo "Error: Invalid option"
|
||||
exit;;
|
||||
esac
|
||||
done
|
||||
|
||||
function panarea {
|
||||
read -p "Diameter of pan (in inches): " DIAM
|
||||
AREA=$(echo "3.1415926535*($DIAM/2)^2" | bc)
|
||||
SIZE=$(echo $AREA*$FSI | bc)
|
||||
calcratio
|
||||
|
@ -19,4 +41,20 @@ function calcratio {
|
|||
done
|
||||
}
|
||||
|
||||
panarea
|
||||
case $1 in
|
||||
*g)
|
||||
SIZE=$(echo $1 | sed s/g//g)
|
||||
calcratio;;
|
||||
*\")
|
||||
DIAM=$(echo $1 | sed s/\"//g)
|
||||
panarea;;
|
||||
*inch)
|
||||
DIAM=$(echo $1 | sed s/inch//g)
|
||||
panarea;;
|
||||
*in)
|
||||
DIAM=$(echo $1 | sed s/in//g)
|
||||
panarea;;
|
||||
*)
|
||||
read -p "Diameter of pan (in inches): " DIAM
|
||||
panarea;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue