You can use a function written in bash script to use like any other Unix/Linux command. This function can take command line arguments and return a value as exit code similar to standard commands. In the following example, we try to identify if a directory exists with the given name. The function returns 1 if a directory exists. Otherwise returns 0. You can copy the following piece of code and keep in a script or paste it on the console.
echo REQ isdir $1
if [ -d "$1" ]; then
export -f isdir
Now let us invoke this as a standard command and examine the return code.