if statement: 'fi' inesperado

0

Eu fiz um shell com uma declaração if, todos os caracteres newline são LF (Linux), quando tento executar o shell, recebo um "erro de sintaxe: 'fi' inesperado".

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

Eu não entendo porque eu recebo este erro, gostaria de salientar que eu uso este script no ambiente Android com Termux, Busybox e tem acesso root.

Eu já verifiquei vários segmentos de usuários com o mesmo problema, mas não encontrei erros.

    
por Rom 25.09.2018 / 12:50

1 resposta

0

O único pensamento que eu não gosto (pode ver que está errado) é

 while printf '%s\n' "$APPSNAMES" | while IFS= read -r line

Dois whiles e apenas um do + concluído

    
por 25.09.2018 / 13:24