Skip to content

Instantly share code, notes, and snippets.

@ducu
Last active July 19, 2017 09:01
Show Gist options
  • Save ducu/94f1c292b6407d1f47b3df9c2c36f62a to your computer and use it in GitHub Desktop.
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
#!/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
@ducu
Copy link
Author

ducu commented Jul 19, 2017

Call the script like this:

bash manage.sh arg1 arg2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment