Browse Source

fix: [compose] catch possible error and bail out

cache-relation
Valentin Lab 11 months ago
parent
commit
bf4da4d8a2
  1. 43
      bin/compose

43
bin/compose

@ -15,6 +15,40 @@
## From kal-shlib ## From kal-shlib
## ##
read-0-err() {
local ret="$1" eof="" idx=0 last=
read -r -- "${ret?}" <<<"0"
shift
while [ "$1" ]; do
last=$idx
read -r -d '' -- "$1" || {
## Put this last value in ${!ret}
eof="$1"
read -r -- "$ret" <<<"${!eof}"
break
}
((idx++))
shift
done
[ -z "$eof" ] || {
if [ "$last" != 0 ]; then
echo "Error: read-0-err couldn't fill all value" >&2
read -r -- "$ret" <<<"127"
else
if [ -z "${!ret}" ]; then
echo "Error: last value is not a number, did you finish with an errorlevel ?" >&2
read -r -- "$ret" <<<"126"
fi
fi
false
}
}
p-err() {
"$@"
echo "$?"
}
_sed_compat_load() { _sed_compat_load() {
if get_path sed >/dev/null; then if get_path sed >/dev/null; then
@ -994,10 +1028,15 @@ run() {
[ -n "$DEBUG" ] && show_env >&2 [ -n "$DEBUG" ] && show_env >&2
if [ -n "$ARG_COMPOSE_FILE" ]; then if [ -n "$ARG_COMPOSE_FILE" ]; then
array_read-0 cmd_args < \
<(replace_compose_file_opt "$COMPOSE_LAUNCHER_HASH" \
while read-0-err E cmd_arg; do
cmd_args+=("$cmd_arg")
done < <(p-err replace_compose_file_opt "$COMPOSE_LAUNCHER_HASH" \
"$COMPOSE_LAUNCHER_BIN_OVERRIDE" \ "$COMPOSE_LAUNCHER_BIN_OVERRIDE" \
"$@") "$@")
if [ "$E" != "0" ]; then
err "Unexpecte failure while trying to replace compose file option."
return 1
fi
set -- "${cmd_args[@]}" set -- "${cmd_args[@]}"
fi fi

Loading…
Cancel
Save