Created
November 13, 2020 17:26
-
-
Save FalconIA/93b7c6817e42b9d45788700e61b799c4 to your computer and use it in GitHub Desktop.
This file contains 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 | |
EXEC_PATH=docker-compose | |
DEFAULT_FILES="*.yml *.yaml" | |
ARGS= | |
FILES= | |
START=1 | |
END=$# | |
ARG_START=$START | |
if [ "$1" == "*" ]; then | |
FILES=$DEFAULT_FILES | |
(( START++ )) | |
fi | |
for i in $(seq $START $END); do | |
arg=${@:$i:1} | |
if [[ "$arg" == *.yml ]]; then | |
FILES="$FILES $arg" | |
else | |
ARG_START=$i | |
break | |
fi | |
done | |
for i in $(seq $ARG_START $END); do | |
arg=${@:$i:1} | |
ARGS="$ARGS $arg" | |
done | |
if [ "$FILES" == "" ]; then | |
FILES=$DEFAULT_FILES | |
fi | |
FILE_ARGS= | |
for file in `ls $FILES 2> /dev/null`; do | |
FILE_ARGS="$FILE_ARGS -f $file" | |
done | |
CMD="$EXEC_PATH $FILE_ARGS $ARGS" | |
echo $CMD | |
$CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment