Created
April 20, 2022 15:12
-
-
Save sam159247/112e188aa6291c80d20eadc35e84673e to your computer and use it in GitHub Desktop.
[shell] subcommand sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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