Subject: Re: bashism for ksh
To: Thorsten Glaser <>
From: Aleksey Cheusov <>
List: tech-userlevel
Date: 09/27/2007 00:00:07
> Aleksey Cheusov dixit:

 >>If you'll add PIPESTATUS (bash/zsh) extension to mksh, it become
 >>really great ;) IMHO PIPESTATUS is extreamly useful for interactive usage.

> What does it?

My prompt (bash) works like this

0 ~>ret5 () { return 5; }
0 ~>ret7 () { return 7; }
0 ~>ret5
5 ~>ret7
7 ~>ret5 | true | ret5
5 0 5 ~>true | false | ret7
0 1 7 ~>false | false
1 1 ~>

Before ~> exit statuses of every program in pipe are shown.
That is, when I run pipe I see how it ended.

In bash this is done via special array (yet another extension) variable

I know that there is a way of portable implementation
of the same functionality but this requires running a pipe
in a special way like this

   runpipe ret 5 '|' true '|' ret5

where runpipe is a special wrapper.

This way is excellent for portable programs but
is too hard for the interactive use.


Based on the code from FAQ of, I wrote this wrapper
and new helper functions and packaged them.

Detailed (but short) documentation is in README file inside tarball.

Best regards, Aleksey Cheusov.