Syntax error: 'fi' unexpected

unzip file.zip
if [[ $? == 0 ]] ; then
echo "Success"
else
echo "Some failure."
fi ;

I tried many time to detect the unzip error, but it keep show the syntax error wherever how I change the syntac. Hope someone can help me fix the issue, thanks.

Which shell you are working?

---------- Post updated at 03:09 AM ---------- Previous update was at 03:00 AM ----------

If this is bash, your code should work fine. It worked for me:
root@host tmp]# ls -lrt
total 30
-rw-r--r-- 1 root  root    200 Sep 16 07:01 test.zip
-rwxrwxrwx 1 root  root     98 Sep 16 07:04 a.sh
root@host tmp]#
root@host tmp]#
root@host tmp]# cat a.sh
#!/bin/bash

unzip test.zip
if [[ $? == 0 ]] ; then
echo "Success"
else
echo "Some failure."
fi ;
root@host tmp]#
root@host tmp]#
root@host tmp]# ./a.sh
Archive:  test.zip
  inflating: test
Success
root@host tmp]#
root@host tmp]# ls -lrt
total 34
-rw-r--r-- 1 root  root    120 Sep 16 06:11 test
-rw-r--r-- 1 root  root    200 Sep 16 07:01 test.zip
-rwxrwxrwx 1 root  root     98 Sep 16 07:04 a.sh 

hi, I worked in bash script in android, but it keep said this syntax error when process it.

I suspect the script file itself is in DOS format. Try converting to UNIX format first:

tr -d '\r' < scriptfile > newscriptfile

---
After that, you will probably also need to change

if [[ $? == 0 ]] ; then

to

if [ $? = 0 ] ; then

or

if [ $? -eq 0 ] ; then

hi, but after I tried, I still meet the issue.
after I add on this at my script.

#!/bin/bash

unzip test.zip
if [[ $? == 0 ]] ; then
echo "Success"
else
echo "Some failure."
fi ;

---------- Post updated at 05:39 PM ---------- Previous update was at 05:37 PM ----------

hi Scrutinizer, it is mean I need write a code to convert my code to UNIX everytime?

It means that when you give a script to bash to execute; that script should always have <newline> line terminators; not DOS/Windows <carriage-return><newline> line terminators.

If you are downloading a freshly corrupted copy of your script every time before you execute it; you need to strip out the <carriage-return> characters every time you execute it.

Once you have removed the <carriage-return> characters; you can execute it as many times as you want until you corrupt it again.