Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using CentOS 6.2. This is my ~/.bash_profile content:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
PATH=$PATH:$HOME/bin

export PATH

However, when I source it using

source .bash_profile

it returns

if: Expression Syntax.

Why?

This is my .bashrc file:

# .bashrc
# Source global definitions

if [ -f /etc/bashrc ]; then

        . /etc/bashrc

fi

# User specific aliases and functions
share|improve this question
2  
How does your ~/.bashrc look? Since it is sourced in .bash_profile, the error might be in there (and probably is). – Daniel Andersson Aug 9 '12 at 9:37
up vote 7 down vote accepted

Perhaps you accidentally ran this from csh?

$ csh
lucid32:~> source if_rc
if: Expression Syntax.
lucid32:~> cat if_rc
if [ -f /etc/bashrc ]; then
    :
fi
share|improve this answer
2  
i changed shell to bash now it's working fine. thanx – max Aug 9 '12 at 10:23
    
How I did this: I had a hunch, having once used tcsh in the grey past. if: Expression Syntax. just did not look like anything that I know from any Bourne/POSIX shell or derivative. Google and a couple of lines of code did the rest. – Henk Langeveld Aug 9 '12 at 14:26
1  
+1: Nice catch. – chepner Aug 9 '12 at 15:10

You must log in to answer this question.

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