This commit is contained in:
Case Duckworth 2020-04-30 21:36:40 +00:00
parent 3b5b22a6bf
commit 6b1091175b
2 changed files with 17 additions and 7 deletions

View File

@ -136,7 +136,6 @@ bakerdemote()
main()
{ # entry point
(( $(id -u) == 0 )) || die "Script must be run as root"
(( $# == 0 )) && usage 1
cmd="$1"; shift || die "Not enough arguments for \"$cmd\""
case "$cmd" in
@ -159,6 +158,7 @@ main()
cmd=demote ;;
esac
(( $(id -u) == 0 )) || die "Script must be run as root"
"baker$cmd" "$@"
}

View File

@ -1,19 +1,29 @@
#!/bin/bash
# make a bread header
: "${BREADS:=🍞 🥖 🥪 🥐 🥟 🌯 🥙 🥨 🥞}"
: "${BREADS:=🍞 🥖 🥐 🌯 🥙 🥞}"
if [ "x$1" = "x-h" ]; then
cat <<END
breader: make a bread header
usage:
breader [NUMBER_OF_BREADS]
NUMBER_OF_BREADS defaults to three.
It'll make a line of bread NUMBER_OF_BREADS long.
END
fi
breader=
for b in $(seq "${1:-3}")
do
nextbread=
until [ -n "$nextbread" ]; do
nextbread="$(
echo "$BREADS" |
while [[ -z "$nextbread" ]]
do
nextbread="$(echo "$BREADS" |
tr ' ' '\n' |
head -n $((RANDOM%(${#BREADS}-1))) |
tail -n1
)"
tail -n1)"
done
breader="$breader $nextbread"
done