The following (bash-only) function seems to have the desired properties. If the command can be run then it is run and its error status is returned; standard output and standard error are processed normally. If the command cannot be run then it is not run and 126 or 127 is returned as the error status and (what we wanted:) no 'command no found' message is printed. trydo() { trydo_sub() { eval "$@" 3>&2 2>&1 1>&3 | { grep -v 'command not found' || : ; } ; return ${PIPESTATUS[0]} ; } trydo_sub "$@" 3>&2 2>&1 1>&3 }
With this function defined one can change the invoke-rc.d example to this: trydo invoke-rc.d <pkg> <method> || case "$?" in (12[67]) /etc/init.d/<pkg> <method> ;; esac -- Thomas Hood <[EMAIL PROTECTED]> -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]