From 0571bdad8c5a285b58be7ba153ec86cda3aa3078 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sat, 21 Nov 2020 19:55:02 +0000 Subject: [PATCH] sde: make `sde` ensure usage of ./run.sh when available Signed-off-by: Alejandro Mery --- bin/sde | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/bin/sde b/bin/sde index 148129f..b3418d1 100755 --- a/bin/sde +++ b/bin/sde @@ -39,6 +39,7 @@ readlink -f /bin/sh 2>&1 > /dev/null if [ "x-x" = "x${1:-}" ]; then XTRACE=yes + PS4='+${BASH_SOURCE:+$BASH_SOURCE:}$LINENO> ' shift set -x else @@ -68,12 +69,39 @@ fi # switching to the right sde wrapper (SDEROOT specific) # if [ "$( readlink -f "$0" )" != "$SDEROOT/bin/sde" ]; then - if [ "$1" = "--loop" ]; then + if [ "--loop" = "${1:-}" ]; then echo_abort 2 'loop detected, abort.' + fi + + set -- ${XTRACE:+-x }--loop "$@" + + if [ -x "$SDEROOT/run.sh" ]; then + exec "$SDEROOT/run.sh" sde --run-loop "$@" else - exec "$SDEROOT/bin/sde" ${XTRACE:+-x }--loop "$@" + exec "$SDEROOT/bin/sde" "$@" + fi +elif [ -x "$SDEROOT/run.sh" ]; then + if [ "yes" = "${SDE_VIA_RUN_SH:-}" ]; then + # good + while [ $# -gt 0 ]; do + case "$1" in + --run-loop|--loop) + ;; + *) + break ;; + esac + shift + done + elif [ "--run-loop" = "${1:-}" ]; then + echo_abort 2 'loop detected, abort.' + else + if [ "--loop" = "${1:-}" ]; then + shift + fi + + exec "$SDEROOT/run.sh" sde ${XTRACE:+-x }--run-loop "$@" fi -elif [ "$1" = "--loop" ]; then +elif [ "--loop" = "${1:-}" ]; then shift fi