Browse Source

chg: dev: avoid ``exit`` in favor of ``return``

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
lokavaluto/dev/master
Valentin Lab 5 years ago
parent
commit
bf3b3fa59f
  1. 29
      bin/compose

29
bin/compose

@ -385,14 +385,14 @@ get_compose_file_opt() {
if [ -n "$override" ]; then
if ! [ -f "$override" ]; then
err "Invalid override of 'compose-core' detected. File '$override' does not exist on host."
exit 1
return 1
fi
hash=$( { p0 "$image_id"; cat "$override"; } | md5_compat)
else
hash=$(p0 "$image_id" | md5_compat)
fi
_get_compose_file_opt "$hash" "$override" "$@" || exit 1
_get_compose_file_opt "$hash" "$override" "$@" || return 1
}
@ -443,13 +443,13 @@ replace_compose_file_opt() {
if [ -n "$override" ]; then
if ! [ -f "$override" ]; then
err "Invalid override of 'compose-core' detected. File '$override' does not exist on host."
exit 1
return 1
fi
hash=$( { p0 "$image_id"; cat "$override"; } | md5_compat)
else
hash=$(p0 "$image_id" | md5_compat)
fi
_replace_compose_file_opt "$hash" "$override" "$@" || exit 1
_replace_compose_file_opt "$hash" "$override" "$@" || return 1
}
@ -682,7 +682,7 @@ set_os() {
;;
*)
echo "System '$os' not supported yet." >&2
exit 1
return 1
;;
esac
}
@ -727,13 +727,12 @@ mk_docker_run_options() {
docker_run_opts+=("-e" "DISABLE_SYSTEM_CONFIG_FILE=$DISABLE_SYSTEM_CONFIG_FILE")
fi
mkdir -p "$COMPOSE_LAUNCHER_CACHE"
mkdir -p "$COMPOSE_LAUNCHER_CACHE" || return 1
## get TZ value and prepare TZ_PATH
TZ=$(get_tz) || exit 1
TZ=$(get_tz) || return 1
mkdir -p "${TZ_PATH}"
TZ_PATH="${TZ_PATH}/$(e "$TZ" | sha256sum | cut -c 1-8)" || exit 1
TZ_PATH="${TZ_PATH}/$(e "$TZ" | sha256sum | cut -c 1-8)" || return 1
[ -e "$TZ_PATH" ] || e "$TZ" > "$TZ_PATH"
## CACHE/DATA DIRS
@ -747,9 +746,9 @@ mk_docker_run_options() {
##
## CHARM_STORE
[ -e "$CHARM_STORE" ] || mkdir -p "$CHARM_STORE" || exit 1
[ -e "$CHARM_STORE" ] || mkdir -p "$CHARM_STORE" || return 1
[ -L "$CHARM_STORE" ] && {
CHARM_STORE=$(readlink -f "$CHARM_STORE") || exit 1
CHARM_STORE=$(readlink -f "$CHARM_STORE") || return 1
}
docker_run_opts+=(
@ -757,7 +756,7 @@ mk_docker_run_options() {
"-e" "CHARM_STORE=/srv/charm-store"
"-e" "HOST_CHARM_STORE=$CHARM_STORE"
)
check_no_links_subdirs "$CHARM_STORE"/* || exit 1
check_no_links_subdirs "$CHARM_STORE"/* || return 1
## DEFAULT_COMPOSE_FILE
if [ "${DEFAULT_COMPOSE_FILE+x}" ]; then
@ -797,7 +796,7 @@ mk_docker_run_options() {
docker_run_opts+=("-e" "COMPOSE_DOCKER_IMAGE=$COMPOSE_DOCKER_IMAGE")
if ! docker_has_image "$COMPOSE_DOCKER_IMAGE"; then
docker pull "$COMPOSE_DOCKER_IMAGE" || exit 1
docker pull "$COMPOSE_DOCKER_IMAGE" || return 1
fi
@ -822,7 +821,7 @@ mk_docker_run_options() {
esac
done < <(list_compose_vars)
compose_file=$(get_compose_file_opt "$COMPOSE_DOCKER_IMAGE" "$@") || exit 1
compose_file=$(get_compose_file_opt "$COMPOSE_DOCKER_IMAGE" "$@") || return 1
if [ -z "$compose_file" ]; then
## Find a compose.yml in parents
@ -833,7 +832,7 @@ mk_docker_run_options() {
echo "$PWD"
exit 0
}
[ "$PWD" == "/" ] && exit 1
[ "$PWD" == "/" ] && return 1
cd ..
done
); then

Loading…
Cancel
Save