Checking number of parameters passed in a function : I'm writing a bash function that takes a directory D as a parameter. If given no parameter, D should be ".", if 2 or more parameters are passed in, the function should output an error and exit the program. 

But my function is not working. Please help!!

````
dir=$@
if [ $# -e 1 ]; then
   dir=$1
else if [ $# -e 0 ]; then
    dir="."
else
    echo "Too many operands."
    exit 1
fi



````