Last active
May 14, 2022 22:22
-
-
Save ahonor/f61569190327c16a293d to your computer and use it in GitHub Desktop.
example wrapper for rerun modules
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
#!/usr/bin/env bash | |
# Wrapper for modules sharing same prefix | |
: ${RERUN:=$(which rerun)} | |
: ${RERUN_MODULE_PREFIX:=rundeck-} | |
if (( $# == 1 )) | |
then | |
exec command $RERUN ${RERUN_MODULE_PREFIX}${1} | |
elif (( $# >= 2 )) | |
then | |
mod=$1 | |
shift | |
exec command $RERUN ${RERUN_MODULE_PREFIX}${mod}: "$@" | |
else | |
. $RERUN | |
for mod in $(rerun_modules $RERUN_MODULES) | |
do | |
regex="${RERUN_MODULE_PREFIX}([a-z]+)" | |
if [[ $mod =~ $regex ]] | |
then | |
echo ${BASH_REMATCH[1]} | |
fi | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment