Trouble understanding shell scripting (mostly wsname)

Am still learning Scripting and I come across a build command that I don't really understand

if /local/bin/wsname 2>/dev/null; then
    base="`/local/bin/wsname`"
    export base
fi
if [ -z "${base}" ]; then
    /local/bin/wsname 
    exit 1
fi
WSNAME="$base"/

can some one in light me to what it should be doing???

Thanks

if /local/bin/wsname 2>/dev/null; then         # run wsname discarding its err msgs and check the exit code; if 0 then
    base="`/local/bin/wsname`"                 # assign the output of wsname to the variable "base"
    export base                                # and export that
fi
if [ -z "${base}" ]; then                      # if base is not set
    /local/bin/wsname                          # run wsname again 
    exit 1                                     # and exit with error code
fi
WSNAME="$base"/                                # assign base's content, extended by a "/" (making up a directory entry?), to the WSNAME variable

For more enlightenment we need to see more context...

1 Like