Compare commits
No commits in common. "c62e20d2512fdc39b1658e648106ea7e476bc78c" and "7a20ba460b58de111ec925094fed79f5dcebc8fe" have entirely different histories.
c62e20d251
...
7a20ba460b
26
pizza.sh
26
pizza.sh
|
@ -27,10 +27,10 @@ function pizzahelp { # this only prints help text
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -a "${XDG_CONFIG_HOME}/pizzacalc/conf" ]; then
|
if [ -a "${XDG_CONFIG_HOME}/pizzacalc/pizza.txt" ]; then
|
||||||
ALTPIZZA="${XDG_CONFIG_HOME}/pizzacalc/conf"
|
ALTPIZZA="${XDG_CONFIG_HOME}/pizzacalc/pizza.txt"
|
||||||
elif [ -a "$HOME/.config/pizzacalc/conf" ]; then
|
elif [ -a "$HOME/.config/pizzacalc/pizza.txt" ]; then
|
||||||
ALTPIZZA="${HOME}/.config/pizzacalc/conf"
|
ALTPIZZA="${HOME}/.config/pizzacalc/pizza.txt"
|
||||||
else
|
else
|
||||||
ALTPIZZA=/dev/null
|
ALTPIZZA=/dev/null
|
||||||
fi
|
fi
|
||||||
|
@ -64,9 +64,9 @@ done
|
||||||
shift $((OPTIND-1)) # shift options out from infront of the command to leave only arugment in $@
|
shift $((OPTIND-1)) # shift options out from infront of the command to leave only arugment in $@
|
||||||
|
|
||||||
function panarea {
|
function panarea {
|
||||||
DFSI=$(cat "$INSTDIR/pizza.txt" | cat - "$ALTPIZZA" | grep -A 1 "\[$RECIPE:ratios\]" | tail -n -1 | cut -f 2-) # find recipe's default flour per squre inch
|
DFSI=$(cat "$INSTDIR/pizza.txt" | cat - "$ALTPIZZA" | grep -A 1 "\[$RECIPE:ratios\]" | tail -n -1 | cut -f 2) # find recipe's default flour per squre inch
|
||||||
FSI="${FSI:-$DFSI}" # dont use default fsi if already set
|
FSI="${FSI:-$DFSI}" # dont use default fsi if already set
|
||||||
AREA=$(echo "3.1415926535*($WIDTH/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 "$COUNT"*$AREA*"$FSI" | bc -l)
|
SIZE=$(echo "$COUNT"*$AREA*"$FSI" | bc -l)
|
||||||
arraytio
|
arraytio
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ function panarea {
|
||||||
function arraytio { # im funny portmantaus are never bad
|
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 '||')
|
||||||
INDEX=0
|
INDEX=0
|
||||||
for RATIO in $(cat "$INSTDIR/pizza.txt" | cat - "$ALTPIZZA" | sed -n "/\[$RECIPE:ratios\]/,/^$/p" | tail -n +3 | cut -f 2-); do # finding [ratios] until the next blank line, removing the first two lines.
|
for RATIO in $(cat "$INSTDIR/pizza.txt" | cat - "$ALTPIZZA" | sed -n "/\[$RECIPE:ratios\]/,/^$/p" | tail -n +3 | cut -f 2); do # finding [ratios] until the next blank line, removing the first two lines.
|
||||||
declare -a INGREDIENT # make arrays
|
declare -a INGREDIENT # make arrays
|
||||||
declare -a MEASURE
|
declare -a MEASURE
|
||||||
((INDEX++)) # increment the index
|
((INDEX++)) # increment the index
|
||||||
|
@ -88,7 +88,7 @@ function arraytio { # im funny portmantaus are never bad
|
||||||
unset SIZE
|
unset SIZE
|
||||||
unset FSI
|
unset FSI
|
||||||
unset AREA
|
unset AREA
|
||||||
unset WIDTH
|
unset DIAM
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
@ -96,17 +96,17 @@ case $1 in # this parses the first argument (and actually calls our main functio
|
||||||
SIZE=$(echo $1 | sed s/g//g)
|
SIZE=$(echo $1 | sed s/g//g)
|
||||||
arraytio;;
|
arraytio;;
|
||||||
+([0-9])?(.)*([0-9])\")
|
+([0-9])?(.)*([0-9])\")
|
||||||
WIDTH=$(echo $1 | sed s/\"//g)
|
DIAM=$(echo $1 | sed s/\"//g)
|
||||||
panarea;;
|
panarea;;
|
||||||
+([0-9])?(.)*([0-9])inch)
|
+([0-9])?(.)*([0-9])inch)
|
||||||
WIDTH=$(echo $1 | sed s/inch//g)
|
DIAM=$(echo $1 | sed s/inch//g)
|
||||||
panarea;;
|
panarea;;
|
||||||
+([0-9])?(.)*([0-9])in)
|
+([0-9])?(.)*([0-9])in)
|
||||||
WIDTH=$(echo $1 | sed s/in//g)
|
DIAM=$(echo $1 | sed s/in//g)
|
||||||
panarea;;
|
panarea;;
|
||||||
*)
|
*)
|
||||||
read -p "Diameter of pan (in inches): " WIDTH
|
read -p "Diameter of pan (in inches): " DIAM
|
||||||
DFSI=$(cat "$INSTDIR/pizza.txt" | cat - "$ALTPIZZA" | grep -A 1 "\[$RECIPE:ratios\]" | tail -n -1 | cut -f 2-)
|
DFSI=$(cat "$INSTDIR/pizza.txt" | cat - "$ALTPIZZA" | grep -A 1 "\[$RECIPE:ratios\]" | tail -n -1 | cut -f 2)
|
||||||
read -p "Flour per square inch [$DFSI]: " FSI
|
read -p "Flour per square inch [$DFSI]: " FSI
|
||||||
panarea;;
|
panarea;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue