I have made a shell with an if statment, all newline characters are LF (Linux), when i try to execute the shell, i get an "syntax error: 'fi' unexpected".
if [ "$(ls -A /storage/$SDCARD_DIR/Android/obb/*/)" ]; then
echo -n -e $Y'One of games folders on your external SDCard has been already moved\n\nTo fix that:\n- We back to main menu\n- Select rs option to restore a specifiq game file in your internal storage\n- Try again to the ma option to move all your games files to your external sdcard'$N
clear && main_menu
else
echo -n -e $C"For info: it's necessary to forcing games apps to be closed"$N; sleep 8;
APPSNAMES=`for dirs in "$INTFOLD"; do printf '%s\n' $dirs | sed -r -e 's/\/storage\/emulated\/0\/Android\/obb\///' | awk -f. '{print $NF}' | sed -r -e 's/\///'`
while printf '%s\n' "$APPSNAMES" | while IFS= read -r line
do
if [ -z $(ps | grep "$line") ]; then
xargs kill
echo -n -e $Y'Game(s) app(s) has been closed\nReady for next step...'$N; sleep 4;
else
echo -n -e $C'No game run in background on your device\nNext step now..'$N; sleep 4;
fi
done
echo -n -e $B'Move all your games to your external SCard...'$N; sleep 5;
for D in `find /storage/emulated/0/Android/obb/ -maxdepth 1 -type d`
do cp -af $D $EXSDCARD
done
for F in `find /storage/emulated/0/Android/obb/ -type f`
do rm -f $F
done
for X in `find "$EXSDCARD" -type F`
do ln -s $X $EXSDCARD
done
echo -n -e $G'All OBB files are now moved to your sdcard\nNB: You could even see files in your internal storage, but they are just linked\n'$N; sleep 7;
echo -n -e $B'Back to main menu...'$N; sleep 5;
main_menu
fi
I don't understand why i get this error, i would like to point out that i use this script on Android environment with Termux, Busybox and got root access.
I have already check several threads of users with the same issue but i don't find any error(s).
while
inwhile printf '%s\n' "$APPSNAMES" | while IFS= read -r line
, only one of which has a correspondingdo
/done
. – Stéphane Chazelas Sep 25 '18 at 10:54APPSNAMES
you use afor
loop. This loop is never closed. Also see https://unix.stackexchange.com/questions/321697 – Kusalananda Sep 25 '18 at 10:56do
in the code, but only fourdone
. At the same time, there are sixfor
orwhile
. – Kusalananda Sep 25 '18 at 11:02