Browse Source

fix: bogus detection of docker-compose arguments.

raw-remaining-args
Valentin Lab 9 years ago
parent
commit
84002aba02
  1. 21
      bin/compose

21
bin/compose

@ -1909,13 +1909,12 @@ _setup_state_dir() {
get_docker_compose_opts_list() {
local cache_file="$CACHEDIR/$FUNCNAME.cache.$(cat "$(which docker-compose)" | md5_compat)"
local action="$1" cache_file="$CACHEDIR/$FUNCNAME.cache.$(echo "$action"; cat "$(which docker-compose)" | md5_compat)"
if [ -e "$cache_file" ]; then
# debug "$FUNCNAME: cache hit ($*)"
cat "$cache_file"
return 0
fi
docker_compose_help_msg=$(docker-compose "$@" --help 2>/dev/null) || return 1
docker_compose_help_msg=$(docker-compose "$action" --help 2>/dev/null) || return 1
echo "$docker_compose_help_msg" | grep '^Options:' -A 20000 |
tail -n +2 |
egrep "^\s+-" |
@ -1927,14 +1926,16 @@ _MULTIOPTION_REGEX='^((-[a-zA-Z]|--[a-zA-Z0-9-]+)(, )?)+'
_MULTIOPTION_REGEX_LINE_FILTER=$_MULTIOPTION_REGEX'(\s|=)'
get_docker_compose_multi_opts_list() {
opts_list=$(get_docker_compose_opts_list "$@") || return 1
local action="$1" opts_list
opts_list=$(get_docker_compose_opts_list "$action") || return 1
echo "$opts_list" | egrep "$_MULTIOPTION_REGEX_LINE_FILTER" |
sed -r "s/^($_MULTIOPTION_REGEX)(\s|=).*$/\1/g" |
tr ',' "\n" | xargs echo
}
get_docker_compose_single_opts_list() {
opts_list=$(get_docker_compose_opts_list "$@") || return 1
local action="$1" opts_list
opts_list=$(get_docker_compose_opts_list "$action") || return 1
echo "$opts_list" | egrep -v "$_MULTIOPTION_REGEX_LINE_FILTER" |
tr ',' "\n" | xargs echo
}
@ -2024,9 +2025,11 @@ while [ "$#" != 0 ]; do
*)
action="$1"
stage="action"
DC_MATCH_MULTI=$(get_docker_compose_multi_opts_list "$action") &&
DC_MATCH_SINGLE="$(get_docker_compose_single_opts_list "$action") $(echo "$DC_MATCH_MULTI" | sed -r 's/( |$)/=\* /g')" &&
DC_MATCH_SINGLE="$(get_docker_compose_single_opts_list "$action")"
if [ "$DC_MATCH_MULTI" ]; then
DC_MATCH_SINGLE="$DC_MATCH_SINGLE $(echo "$DC_MATCH_MULTI" | sed -r 's/( |$)/=\* /g')"
fi
is_docker_compose_action=true
;;
esac
@ -2039,10 +2042,10 @@ while [ "$#" != 0 ]; do
;;
--*|-*)
if [ "$is_docker_compose_action" ]; then
if str_matches "$1" DC_MATCH_MULTI; then
if str_matches "$1" $DC_MATCH_MULTI; then
action_opts=("$1" "$2")
shift;
elif str_matches "$1" DC_MATCH_SINGLE; then
elif str_matches "$1" $DC_MATCH_SINGLE; then
action_opts=("$1")
else
err "Unknown option '$1'. Please check help."

Loading…
Cancel
Save