All pastes #375846 Raw Edit

awesomess3 solution

public shellscript v1 · immutable
#375846 ·published 2007-02-28 17:43 UTC
rendered paste body
#!/bin/bashusage(){  cat <<EOFfindexe [name_of_bin]for example:  findexe vimprints out the path of the binary.returns 0 on success.        1 on failure.EOF  exit 1}[ $# -eq 1 ] || usagesearchit="$1"while read f ; do   if [ $(basename $f) = $searchit ] ; then     echo $f     exit 0  fidone < <(whereis $searchit | tr ' ' '\n')exit 1#--------------------------------------------------# Test drive:# # $: bash testerrno.sh vim# /usr/bin/vim# $: echo $?    -- the $? gives us the return value of the script# 0# $: bash testerrno.sh vi# /usr/bin/vi# $: echo $?# 0# $: bash testerrno.sh v# $: echo $?# 1#--------------------------------------------------