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.
if: Expression Syntax
is not an error bash would give you. Perhaps your shell is not bash. In fact, as long as if
stands alone, any error would not be with if
itself:
$ if [somethingswrong]; then fail; fi # error, then `[` command must have space around it.
-bash: [somethingswrong]: command not found
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With