List Info

Thread: Re: bashism for ksh




Re: bashism for ksh
country flaguser name
Belarus
2007-09-26 16: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
PIPESTATUS.

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.

P.S.

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

   http://mova.
org/~cheusov/pub/pipestatus/

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

-- 
Best regards, Aleksey Cheusov.

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )