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
-f <N> Set flour per square inch
Notes:
Returns weight in grams
Typically a 10 minute pan rise is needed
The dough can be kept overnight in the refidgerator if needed
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 " -f <N> Set flour per square inch"
echo "Notes:"
echo " Returns weight in grams"
echo " Typically a 10 minute pan rise is needed"
echo " The dough can be kept overnight in the refidgerator if needed"
echo " Water can also be used in place of beer"
@ -53,22 +54,19 @@ done
function panarea {
AREA=$(echo "3.1415926535*($DIAM/2)^2" | bc -l) # bc cant exponentiate non-integer bases without -l
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 '||')
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.
declare -a INGREDIENT # make arrays
declare -a MEASURE
((INDEX++)) # increment the index
INGREDIENT[$INDEX]=$(sed -n '/\[ratios\]/,/^$/p' "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 1 | sed $INDEX'!d') # same deal but itterating through the INDEX
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
((LABEL++))
sed -n '/\[ratios\]/,/^$/p' "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 1 | sed $LABEL'!d' # same deal but itterating through the labels
echo "scale = 2; ($RATIO*$SIZE)/1" | bc -l # actually print the calculated number for each label
done # we have to divide by 1 to get the base to reset to actually apply the scale
# cleanup
unset INDEX
unset LABEL
unset RATIO
unset SIZE
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
*g)
SIZE=$(echo $1 | sed s/g//g)
arraytio;;
calcratio;;
*\")
DIAM=$(echo $1 | sed s/\"//g)
panarea;;