I have written the following .bashrc :
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
function up( )
{
LIMIT=$1
P=$PWD
for ((i=1; i <= LIMIT; i++))
do
P=$P/..
done
cd $P
export MPWD=$P
}
function back( )
{
LIMIT=$1
P=$MPWD
for ((i=1; i <= LIMIT; i++))
do
P=${P%/..}
done
cd $P
export MPWD=$P
}
However, after saving, when I did source .bashrc, i got the following error: if: Expression Syntax.
What am I doing wrong ? I googled a while but no avail.
is not an error bash would give you. Perhaps your shell is not bash. In fact, as long as
ifstands alone, any error would not be withifitself:You can check your shell by echoing
$SHELL, and you can check which version of bash with$BASH_VERSION. (If the latter is unset, your shell is not bash.)