Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!rutgers!columbia!douglass!dupuy From: dupuy@douglass.columbia.edu (Alexander Dupuy) Newsgroups: comp.unix.questions Subject: Re: Shouting the return code. (Re: Meaning of "rc" in cron/log) Message-ID: <5739@columbia.edu> Date: 30 Jun 88 22:00:30 GMT References: <717@mccc.UUCP> <16377@tut.cis.ohio-state.edu> <3671@psuvax1.cs.psu.edu> <16500@tut.cis.ohio-state.edu> Sender: nobody@columbia.edu Reply-To: dupuy@douglass.columbia.edu (Alexander Dupuy) Followup-To: comp.unix.questions Distribution: na Organization: Columbia University Computer Science Dept. Lines: 47 In <3671@psuvax1.cs.psu.edu>, flee@gondor.cs.psu.edu (Felix Lee) writes: > Does ksh let you put the return code in the prompt? Something like > PS1='($?) '? ... > Showing only non-zero return codes would be better. Here's what I do in my .kshrc ($ENV) file: status() { integer status=$? if [ $status -gt 128 -a $status -lt 160 ]; then echo "[Signal `expr $status - 128`]" else echo "[Status $status]" fi } trap 'status 1>&2' ERR # don't let commands fail silently With this, if any command exits with non-zero status, I see what it is. If there's no display, I know the status code was 0. Something similar works for csh or SVR2 sh, but there is no ERR trap, so you have to invoke it manually after every command. SVR2 sh: status() { status=$? if [ $status -gt 128 -a $status -lt 160 ]; then echo "[Signal `expr $status - 128`]" else echo "[Status $status]" fi unset status } csh: alias status 'echo "[Status $status]"' @alex -- inet: dupuy@columbia.edu uucp: ...!rutgers!columbia!dupuy