Subject: Re: bashism for ksh
To: None <tech-userlevel@netbsd.org>
From: Thorsten Glaser <tg@mirbsd.de>
List: tech-userlevel
Date: 09/27/2007 12:53:37
Peter Bex dixit:

>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
>wait(2).

True. He or you might be creating a patch.

>In zsh, I have this neat expression as part of my PROMPT variable:
>%B%(?0..(%?%))
>
>It's unreadable, but it means:
>"print in bold the following:

PS1=3D"^A^M${USER}@${HOSTNAME%%.*}"'^A^[[1m^A=E2=80=A6

>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."

=E2=80=A6$(((e=3D$?))&&print "($e)")^A^[[0m^A'

The stock dot.mkshrc example contains something like that (and if you
check out mksh-current via anoncvs, you even get pushd/popd/dirs csh-
like (even implemented to behave exactly like (open)bsd csh, and the
zsh-like precmd() and chpwd() hooks=E2=80=A6 users requested it=E2=80=A6).

bye,
//mirabilos
--=20
I believe no one can invent an algorithm. One just happens to hit upon it
when God enlightens him. Or only God invents algorithms, we merely copy the=
m.
If you don't believe in God, just consider God as Nature if you won't deny
existence.=09=09-- Coywolf Qi Hunt