0

When I open my terminal I get the following error:

bash: /home/ai/.bashrc: line 75: syntax error near unexpected token `['
bash: /home/ai/.bashrc: line 75: `if [ -x /usr/bin/dircolors ]; then'

The relevant part of the bashrc file script starting with the comment is as follows:

# enable color support of ls and also add handy aliases

if [ -x /usr/bin/dircolors ]; then

    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'

fi

What am I doing wrong and how to correct this?

2
  • 6
    Can you post the whole file to pastebin or something? I suspect that the error is before line 75.
    – phunehehe
    Commented Sep 23, 2013 at 12:32
  • @ phunehehe, Hi! I pasted the whole thing at pastebin.com under the name: whole bashrc file-amai14 (Here [link] (pastebin.com/2scppXxi) Please have a look! Commented Sep 23, 2013 at 13:50

2 Answers 2

3

Looking at your pastebin link, you're missing an esac to end the case statement right before the problematic block.

2
  • @ JosephR and @slm. Your answers accepted! Adding esac at the end of the block resolved the problem. Commented Sep 23, 2013 at 15:01
  • 1
    @user2561310 Thanks. What slm meant by accepting the answer, however, is to click on the tick mark button under the vote buttons to the left of the answer. This lets somebody browsing the question listing know that this question already has a valid answer without the need to actually click on it and read the comments.
    – Joseph R.
    Commented Sep 23, 2013 at 15:08
1

The error is most likely occurring before this block of code. For example, if I put this block of code in it's own script and echo the aliases lines out:

#!/bin/bash

# example.bash
if [ -x /usr/bin/dircolors ]; then

    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    echo "alias ls='ls --color=auto'"
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    echo "alias grep='grep --color=auto'"
    echo "alias fgrep='fgrep --color=auto'"
    echo "alias egrep='egrep --color=auto'"

fi

I get this:

$ ./example.bash 
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

Which indicates that it's fine.

Terminating case block

This block doesn't have a corresponding esac.

case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)

....
3
  • @ slm. Thanks! Yes, you are right! Please see my whole bashrc script file at pastebin (link above). Commented Sep 23, 2013 at 13:54
  • Adding esac at the end of the block has removed the error! Commented Sep 23, 2013 at 14:39
  • 1
    @user2561310 - good, please accept either mine or JosephR's answer so that others know your issue's resolved.
    – slm
    Commented Sep 23, 2013 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .