Skip to content

Instantly share code, notes, and snippets.

@FalconIA
Created November 13, 2020 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FalconIA/93b7c6817e42b9d45788700e61b799c4 to your computer and use it in GitHub Desktop.
Save FalconIA/93b7c6817e42b9d45788700e61b799c4 to your computer and use it in GitHub Desktop.
#!/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