Compare commits
2 Commits
b93a0248eb
...
f1ceda284a
Author | SHA1 | Date |
---|---|---|
ida schmidt | f1ceda284a | |
ida schmidt | bba866cedf |
|
@ -11,7 +11,6 @@ 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
|
||||||
|
|
22
pizza.sh
22
pizza.sh
|
@ -13,7 +13,6 @@ 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"
|
||||||
|
@ -54,19 +53,22 @@ 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)
|
||||||
calcratio
|
arraytio
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcratio { # this is mildly hacky
|
function arraytio { # im funny portmantaus are never bad
|
||||||
[ -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 '||')
|
||||||
LABEL=0
|
INDEX=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.
|
||||||
((LABEL++))
|
declare -a INGREDIENT # make arrays
|
||||||
sed -n '/\[ratios\]/,/^$/p' "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 1 | sed $LABEL'!d' # same deal but itterating through the labels
|
declare -a MEASURE
|
||||||
echo "scale = 2; ($RATIO*$SIZE)/1" | bc -l # actually print the calculated number for each label
|
((INDEX++)) # increment the index
|
||||||
done # we have to divide by 1 to get the base to reset to actually apply the scale
|
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
|
||||||
# cleanup
|
# cleanup
|
||||||
unset LABEL
|
unset INDEX
|
||||||
unset RATIO
|
unset RATIO
|
||||||
unset SIZE
|
unset SIZE
|
||||||
unset FSI
|
unset FSI
|
||||||
|
@ -77,7 +79,7 @@ function calcratio { # this is mildly hacky
|
||||||
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)
|
||||||
calcratio;;
|
arraytio;;
|
||||||
*\")
|
*\")
|
||||||
DIAM=$(echo $1 | sed s/\"//g)
|
DIAM=$(echo $1 | sed s/\"//g)
|
||||||
panarea;;
|
panarea;;
|
||||||
|
|
Loading…
Reference in New Issue