Subject: Re: bashism for ksh
To: None <tech-userlevel@NetBSD.org>
From: Peter Bex <Peter.Bex@xs4all.nl>
Date: 09/27/2007 09:22:14
Content-Type: text/plain; charset=us-ascii
On Wed, Sep 26, 2007 at 09:09:04PM +0000, Thorsten Glaser wrote:
> Aleksey Cheusov dixit:
> >7 ~>ret5 | true | ret5
> >5 0 5 ~>true | false | ret7
> >0 1 7 ~>false | false
> Ah okay. This is not easily possible because the parts of the pipe
> are run in subshells. I guess that means deep code changes.
Afaik the subshell returns the exit status of the last command it
runs. Thus you can just reap the exit status of the subshell with
> If you offer a patch, documentation (patch for manpage), and a
> list what other shells have this functionality and how it works
> in these, I might consider including it though.
In zsh, I have this neat expression as part of my PROMPT variable:
It's unreadable, but it means:
"print in bold the following:
if the previous command's exit status was 0, display nothing (empty
string between the first and second dot), if it was nonzero, display
the exit status between brackets."
So whenever a command terminated with an error, it alerts me by
changing my prompt from
with the (1) part in bold.
It's great because it only draws attention to itself when something out
of the ordinary is happening, and keeps the prompt clean otherwise.
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)
-----END PGP SIGNATURE-----