Invalid option for dirname
===

I have a simple script called abc.sh as follows, that sets the environment variables


    #!/bin/bash
    sourcePath () {
    filename=`basename $0`

    current_dir="./"$filename
    if [ "$current_dir" = "$0" ]; then        SRC_DIR=$(pwd) 
             SRC_DIR=$(cd "$SRC_DIR/.."; pwd)
    else        SRC_DIR=$(cd "$(dirname "$0")/.."; pwd)
    fi
    }

    sourcePath
    echo $SRC_DIR
    export SRC_DIR

I would like this script to set the variable SRC_DIR in my current shell environment. Hence, when i do source abc.sh, i get an error saying invalid options to dirname.
But if i run this file with ./abc.sh, i dont get any error, but then it wont export the variable