diff --git a/get_latest_image.sh b/get_latest_image.sh index 1044caaf88..66916b3545 100755 --- a/get_latest_image.sh +++ b/get_latest_image.sh @@ -43,12 +43,18 @@ fi IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" -# If there are no images, return nothing -[ -d $IMAGES_DIR ] || exit 0 +# If there are no images, error out since presumably the +# caller isn't doing this for fun. +if [[ ! -d ${IMAGES_DIR} ]] ; then + die "${IMAGES_DIR} does not exist; have you run ./build_image?" +fi # Use latest link if it exists, otherwise most recently changed dir if [ -L ${IMAGES_DIR}/latest ] ; then - DEFAULT_FROM="${IMAGES_DIR}/`readlink ${IMAGES_DIR}/latest`" + if ! dst=$(readlink "${IMAGES_DIR}"/latest) ; then + die "Could not read ${IMAGES_DIR}/latest; have you run ./build_image?" + fi + DEFAULT_FROM="${IMAGES_DIR}/${dst}" else DEFAULT_FROM=$(ls -dt "$IMAGES_DIR"/*/ | head -1) fi