Compare commits

..

2 commits

Author SHA1 Message Date
ida
b93a0248eb stop hardcoding recipe length 2023-06-06 23:28:20 -07:00
ida
c5771723f8 comment changes 2023-06-06 18:12:39 -07:00

View file

@ -31,7 +31,7 @@ function pizzarecipe {
echo " 7: rise for 10 minutes"
echo " 8: add sauce, toppings"
echo " 9: bake at 550f until done"
echo ""
echo
}
while getopts ":hrf:" option; do # loop through options, casing them
@ -58,13 +58,13 @@ function panarea {
}
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 '||')
LABEL=0
for RATIO in $(grep 'ratios' -A 8 "$PWD/pizza.txt" | sed /\\[*.\\]/d | cut -f 2); do # finding [ratios] +8 tailing lines, removing the first.
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++))
grep 'ratios' -A 8 "$PWD/pizza.txt" | sed /\\[*.\\]/d | cut -f 1 | sed $LABEL'!d' # same deal but itterating through the labels
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
done # we have to divide by 1 to get the base to reset to actually apply the scale
# cleanup
unset LABEL
unset RATIO