Last active
July 19, 2017 09:01
-
-
Save ducu/94f1c292b6407d1f47b3df9c2c36f62a to your computer and use it in GitHub Desktop.
Call a bash script with arguments as function names to be executed orderly
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/bash | |
## Manage component | |
function arg1() { | |
echo "Function arg1" | |
} | |
function arg2() { | |
echo "Function arg2" | |
} | |
function execute() { | |
# $arg1 && $arg2 etc | |
ops=("$*") | |
for op in ${ops[*]}; do | |
if (!($op)); then | |
echo "ERROR executing $op" | |
break | |
fi | |
done | |
} | |
if [ $# -gt 0 ]; then | |
execute $* | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Call the script like this:
bash manage.sh arg1 arg2