Skip to content

Instantly share code, notes, and snippets.

@sam159247
Created April 20, 2022 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam159247/112e188aa6291c80d20eadc35e84673e to your computer and use it in GitHub Desktop.
Save sam159247/112e188aa6291c80d20eadc35e84673e to your computer and use it in GitHub Desktop.
[shell] subcommand sample
#!/bin/sh
######################################################################
#
# SHELL subcommand and argument sample
#
# USAGE:
# bash asd.sh A
# bash asd.sh B 123
######################################################################
function A {
echo "A"
}
function B {
input=$1
echo ${input}
}
subcmd="$1"
shift
case "$subcmd" in
"A")
A "$@"
;;
"B")
B "$@"
;;
*)
echo "[!] Unknown subcommand"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment