#!/data/data/com.termux/files/usr/bin/bash
basedir=$(dirname "$0")
#unset LD_PRELOAD in case termux-exec is installed. If termux-exec is also installed inside the jail it will set again.
unset LD_PRELOAD
command="proot"
command =" -r $basedir/termux-fs"
command =" -b /system"
command =" -b /dev/"
command =" -b /sys/"
command =" -b /etc/"
command =" -b /proc/"
command =" -b /vendor"
command =" -b /data/dalvik-cache/"
command =" -b /property_contexts"
if [ -n "$(ls -A "$basedir"/binds)" ]; then
for f in $basedir/binds/* ;do
. "$f"
done
fi
command =" -w /data/data/com.termux/files/home/"
command =" /data/data/com.termux/files/usr/bin/env -i"
command =" HOME=/data/data/com.termux/files/home"
command =" PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets"
command =" TERM=$TERM"
command =" ANDROID_DATA=/data"
command =" ANDROID_ROOT=/system"
command =" EXTERNAL_STORAGE=/sdcard"
command =" LANG=$LANG"
command =" LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib"
command =" PREFIX=/data/data/com.termux/files/usr"
command =" TMPDIR=/data/data/com.termux/files/usr/tmp"
com="$@"
if [ -z "$com" ];then
eval "exec $command login"
else
eval "exec $command login -c "$com""
fi
Error
./start.sh: line 39: unexpected EOF while looking for matching `"'
./start.sh: line 41: syntax error: unexpected end of file
Every double quotes are closed why it keeps throwing error Tried running through sh instead of bash but still errors
also it shows erros on command =" -b /system" about closing double quotes can anyone explain?
CodePudding user response:
Recheck string:
eval "exec $command login -c "$com""
You have to escape double quotes in shell.
https://unix.stackexchange.com/questions/30903/how-to-escape-quotes-in-shell
CodePudding user response:
You don't need eval
. Use arrays to store the arguments for the command.
#!/data/data/com.termux/files/usr/bin/bash
basedir=$(dirname "$0")
#unset LD_PRELOAD in case termux-exec is installed. If termux-exec is also installed inside the jail it will set again.
unset LD_PRELOAD
command="proot"
command_args=(
-r "$basedir/termux-fs"
-b /system
-b /dev/
-b /sys/
-b /etc/
-b /proc/
-b /vendor
-b /data/dalvik-cache/
)
command_args =(-b /property_contexts)
shopt -s nullglob
for f in "$basedir"/binds/*; do
. "$f"
done
command_args =(
-w /data/data/com.termux/files/home/
/data/data/com.termux/files/usr/bin/env -i
HOME=/data/data/com.termux/files/home
PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
"TERM=$TERM"
ANDROID_DATA=/data
ANDROID_ROOT=/system
EXTERNAL_STORAGE=/sdcard
"LANG=$LANG"
LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib
PREFIX=/data/data/com.termux/files/usr
TMPDIR=/data/data/com.termux/files/usr/tmp
)
command_args =(login)
if (( $# == 0 )); then
command_args =( -c "$@" )
fi
exec "$command" "${command_args[@]}"