可以换个角度,这样考虑,试图替换原字符串中的模式串内容:
function substr
{
    STRING_A=$1
    STRING_B=$2
    if [[ ${STRING_A/${STRING_B}//} == $STRING_A ]]
    then
        ## is not substring.
        echo N
        return 0
    else
        ## is substring.
        echo Y
        return 1
    fi
}
substr "ThisIsAString" "SUBString" # should output N
substr "ThisIsAString" "String" # should output Y