Replace case with a function call

This commit is contained in:
MaanooAk 2020-05-31 01:19:14 +03:00
parent 3222354d50
commit 32c88a2f13

View File

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
COMMAND="${1:-help}"
NUM="${2:-5}" NUM="${2:-5}"
# Uncomment the following line to use Pulseaudio. # Uncomment the following line to use Pulseaudio.
@ -19,10 +20,12 @@ else
control() { alsamixer ;} control() { alsamixer ;}
fi fi
case "$1" in help() {
toggle) toggle ;; echo "usage: lmc <command> [<num>]"
mute) mute ;; echo "commands:"
up) up ;; sed -n 's/^\s*\(\S*\)().*/- \1/p' "$0" | sort -u
down) down ;; }
control) control ;;
esac type "$COMMAND" | grep function >/dev/null && "$COMMAND" \
|| echo "lmc: command not defined: $COMMAND" >&2