Compare commits

..

No commits in common. "f1ceda284a366d7e46a9d13f5f54f274a282f8bf" and "b93a0248eb72c3400fe8e34f791b411d2ab0750c" have entirely different histories.

2 changed files with 11 additions and 12 deletions

View File

@ -11,6 +11,7 @@ Options:
-r Print the recipe -r Print the recipe
-f <N> Set flour per square inch -f <N> Set flour per square inch
Notes: Notes:
Returns weight in grams
Typically a 10 minute pan rise is needed Typically a 10 minute pan rise is needed
The dough can be kept overnight in the refidgerator if needed The dough can be kept overnight in the refidgerator if needed
Water can also be used in place of beer Water can also be used in place of beer

View File

@ -13,6 +13,7 @@ function pizzahelp { # this only prints help text
echo " -r Print the recipe" echo " -r Print the recipe"
echo " -f <N> Set flour per square inch" echo " -f <N> Set flour per square inch"
echo "Notes:" echo "Notes:"
echo " Returns weight in grams"
echo " Typically a 10 minute pan rise is needed" echo " Typically a 10 minute pan rise is needed"
echo " The dough can be kept overnight in the refidgerator if needed" echo " The dough can be kept overnight in the refidgerator if needed"
echo " Water can also be used in place of beer" echo " Water can also be used in place of beer"
@ -53,22 +54,19 @@ done
function panarea { function panarea {
AREA=$(echo "3.1415926535*($DIAM/2)^2" | bc -l) # bc cant exponentiate non-integer bases without -l AREA=$(echo "3.1415926535*($DIAM/2)^2" | bc -l) # bc cant exponentiate non-integer bases without -l
SIZE=$(echo $AREA*$FSI | bc) SIZE=$(echo $AREA*$FSI | bc)
arraytio calcratio
} }
function arraytio { # im funny portmantaus are never bad function calcratio { # this is mildly hacky
[ -n SIZE ] || read -p "Grams of flour: " SIZE # test ([) will send a non-zero exit code on if $SIZE doesnt exist, tripping the or (the '||') [ -n SIZE ] || read -p "Grams of flour: " SIZE # test ([) will send a non-zero exit code on if $SIZE doesnt exist, tripping the or (the '||')
INDEX=0 LABEL=0
for RATIO in $(sed -n '/\[ratios\]/,/^$/p' "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 2); do # finding [ratios] until the next blank line, removing the first line. for RATIO in $(sed -n '/\[ratios\]/,/^$/p' "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 2); do # finding [ratios] until the next blank line, removing the first line.
declare -a INGREDIENT # make arrays ((LABEL++))
declare -a MEASURE sed -n '/\[ratios\]/,/^$/p' "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 1 | sed $LABEL'!d' # same deal but itterating through the labels
((INDEX++)) # increment the index echo "scale = 2; ($RATIO*$SIZE)/1" | bc -l # actually print the calculated number for each label
INGREDIENT[$INDEX]=$(sed -n '/\[ratios\]/,/^$/p' "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 1 | sed $INDEX'!d') # same deal but itterating through the INDEX done # we have to divide by 1 to get the base to reset to actually apply the scale
MEASURE[$INDEX]=$(echo "scale = 2; ($RATIO*$SIZE)/1" | bc -l) # we have to divide by 1 to actually apply the scale
echo ${INGREDIENT[$INDEX]}: ${MEASURE[$INDEX]}g # actually print the calculated number with label for each INDEX
done
# cleanup # cleanup
unset INDEX unset LABEL
unset RATIO unset RATIO
unset SIZE unset SIZE
unset FSI unset FSI
@ -79,7 +77,7 @@ function arraytio { # im funny portmantaus are never bad
case $1 in # this parses the first argument (and actually calls our main functions), the units need to be removed before bc will accept it case $1 in # this parses the first argument (and actually calls our main functions), the units need to be removed before bc will accept it
*g) *g)
SIZE=$(echo $1 | sed s/g//g) SIZE=$(echo $1 | sed s/g//g)
arraytio;; calcratio;;
*\") *\")
DIAM=$(echo $1 | sed s/\"//g) DIAM=$(echo $1 | sed s/\"//g)
panarea;; panarea;;