Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.