[Gllug] show non-zero exit code in bash
Dean Wilson
dwilson at unixdaemon.net
Fri Dec 23 14:42:27 UTC 2005
I have shell envy. One of my co-workers uses zsh and has a nifty feature
that shows you the exit code of any command that doesn't return a 0.
I'd like to do the same thing in bash but I've hit a stumbling block. The
following PROMPT_COMMAND does most of what I want:
PROMPT_COMMAND='ret=$?; if [ "$ret" -ne "0" ];then echo exit code: $ret;fi'
But it has a bug.
If you type ls and then press return a lot everything is fine and nothing
gets shown.
If you type "ls file_name_thats_not_real" it echos 1 as you'd expect.
But when you press return it puts the 1 out each time. I've had a fiddle
and I can't see a way around this. Any suggestions?[0]
Dean
[0] Other than use zsh. Or don't press return after a bad command.
--
Dean Wilson http://www.unixdaemon.net
Profanity is the one language all programmers understand
--- Anon
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list