Fix ensure_bb by assigning the arguments propery

If we assign the execution output directly it will fail (tested on Android 11):

pdx201:/ # INSTALLER=/data/adb/magisk_install /data/adb/magisk_install/flash_script.sh                                                                          
/data/adb/magisk_install/flash_script.sh[31]: typeset: -o: is not an identifier

Because:

local cmds=$($bb sh -o standalone -c "
	  for arg in \$(tr '\0' '\n' < /proc/$$/cmdline); do
	    if [ -z \"\$cmds\" ]; then
	      # Skip the first argument as we want to change the interpreter
	      cmds=\"sh -o standalone\"
	    else
	      cmds=\"\$cmds '\$arg'\"
	    fi
	  done
	  echo \$cmds")
/system/bin/sh: typeset: -o: is not an identifier

Signed-off-by: Pablo Mendez Hernandez <pablomh@gmail.com>
This commit is contained in:
pablomh 2020-10-14 10:42:26 +02:00 committed by John Wu
parent afebe734b8
commit bd1dd9d863

View File

@ -114,7 +114,7 @@ ensure_bb() {
# Find our current arguments # Find our current arguments
# Run in busybox environment to ensure consistent results # Run in busybox environment to ensure consistent results
# /proc/<pid>/cmdline shall be <interpreter> <script> <arguments...> # /proc/<pid>/cmdline shall be <interpreter> <script> <arguments...>
local cmds=$($bb sh -o standalone -c " local cmds="$($bb sh -o standalone -c "
for arg in \$(tr '\0' '\n' < /proc/$$/cmdline); do for arg in \$(tr '\0' '\n' < /proc/$$/cmdline); do
if [ -z \"\$cmds\" ]; then if [ -z \"\$cmds\" ]; then
# Skip the first argument as we want to change the interpreter # Skip the first argument as we want to change the interpreter
@ -123,7 +123,7 @@ ensure_bb() {
cmds=\"\$cmds '\$arg'\" cmds=\"\$cmds '\$arg'\"
fi fi
done done
echo \$cmds") echo \$cmds")"
# Re-exec our script # Re-exec our script
echo $cmds | $bb xargs $bb echo $cmds | $bb xargs $bb