FIX: re-exec code was broken
authorMichael Brown <supermathie@gmail.com>
Wed, 15 Jul 2020 16:50:35 +0000 (12:50 -0400)
committerMichael Brown <supermathie@gmail.com>
Wed, 15 Jul 2020 17:00:04 +0000 (13:00 -0400)
* BASH_ARGV is only used in extended debugging mode

launcher

index 4c9ebb77a894f0b137ea4430cad3e36b99bb1bd3..0153305d4300edeec2d0ee95a2a29e0d787673f2 100755 (executable)
--- a/launcher
+++ b/launcher
@@ -23,6 +23,9 @@ usage () {
   exit 1
 }
 
+# for potential re-exec later
+SAVED_ARGV=("$@")
+
 command=$1
 config=$2
 
@@ -788,14 +791,11 @@ case "$command" in
           echo "Launcher is up-to-date"
 
         elif [ $LOCAL = $BASE ]; then
-          echo "Updating Launcher"
+          echo "Updating Launcher..."
           git pull || (echo 'failed to update' && exit 1)
 
-          for (( i=${#BASH_ARGV[@]}-1,j=0; i>=0,j<${#BASH_ARGV[@]}; i--,j++ ))
-          do
-            args[$j]=${BASH_ARGV[$i]}
-          done
-          exec bash $0 "${args[@]}" # $@ is empty, because of shift at the beginning. Use BASH_ARGV instead.
+          echo "Launcher updated, restarting..."
+          exec "$0" "${SAVED_ARGV[@]}"
 
         elif [ $REMOTE = $BASE ]; then
           echo "Your version of Launcher is ahead of origin"