Skip to content

Instantly share code, notes, and snippets.

@badsyntax
Created July 26, 2013 13:42
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save badsyntax/6088936 to your computer and use it in GitHub Desktop.
Save badsyntax/6088936 to your computer and use it in GitHub Desktop.
A basic example showing the concept of callback functions in bash.
migrate_module() {
echo -e "\nRunning migration for module $1"
protected/yiic migrate --migrationPath=application.modules.$1.migrations
}
loop_modules() {
for file in `ls $MODULE_PATH`; do
if [ -d "$MODULE_PATH/$file" ] && [[ $file =~ ^$MODULE_REGEX ]]; then
$1 "$file"
fi
done
}
loop_modules migrate_module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment