From 02e1d669df14c574a40aa2f8f668073f26dc33bd Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 16 Dec 2015 13:53:26 +0000 Subject: [PATCH] Exit with a value of 1 when cd fails in the init script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Exiting with 0 when cd fails is likely to be incorrectly interpreted as success so we should exit with a non-zero value. Ideally, the init script status action would exit with 4 but, at the point when the cd is performed, we don’t even know if we’re running as an init script. Exiting with 1 seems to be a reasonable compromise as it’s fine for the non init-script case as well as being correct for all init script actions other than status. See gh-4653 --- .../org/springframework/boot/loader/tools/launch.script | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script index 7b5abb88873..3ed80e90709 100755 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script @@ -29,16 +29,16 @@ WORKING_DIR="$(pwd)" [[ -n "$APP_NAME" ]] && identity="$APP_NAME" # Follow symlinks to find the real jar and detect init.d script -cd "$(dirname "$0")" || exit +cd "$(dirname "$0")" || exit 1 [[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0") while [[ -L "$jarfile" ]]; do [[ "$jarfile" =~ init\.d ]] && init_script=$(basename "$jarfile") jarfile=$(readlink "$jarfile") - cd "$(dirname "$jarfile")" || exit + cd "$(dirname "$jarfile")" || exit 1 jarfile=$(pwd)/$(basename "$jarfile") done jarfolder="$(dirname "$jarfile")" -cd "$WORKING_DIR" || exit +cd "$WORKING_DIR" || exit 1 # Source any config file configfile="$(basename "${jarfile%.*}.conf")"