Skip to main content
edited tags
Link
ilkkachu
  • 148.1k
  • 16
  • 268
  • 441
Source Link
code-8
  • 482
  • 1
  • 7
  • 19

syntax error near unexpected token `elif' on 2 levels if-else check

I kept getting this error when I SSHed into my box.

-bash: /root/.bashrc: line 65: syntax error near unexpected token `elif'                                                                          
-bash: /root/.bashrc: line 65: `elif [ -n "$BASH_VERSION" ]; then' 

This is what I have on these lines

if [ -n "$ZSH_VERSION" ]; then
   # assume Zsh
elif [ -n "$BASH_VERSION" ]; then
    PS1="⚡️$yellow $dircolor \W $lightpurple $white"
    if [ $USER == 'root' ]
    then
        export PS1="$white┌──[$red\u$white@$red\h$white]──$white[$red\w$white] \n└── $white"
    else
        export PS1="$white┌──[$lightgreen\u$white@$lightgreen\h$white]──$white[$lightgreen\w$white] \n└── $white"
    fi
else
    # assume something else
fi

I'm only check if zsh/bash and set my PS1 accordingly.

Am I doing something wrong on my syntax ?