9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sed oddity
@ 2009-08-18 14:41 hugo rivera
  2009-08-18 14:55 ` Uriel
  2009-08-18 15:38 ` erik quanstrom
  0 siblings, 2 replies; 7+ messages in thread
From: hugo rivera @ 2009-08-18 14:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hi,
is there some reason why sed doesn't check for write errors on its
stdout? (or at least it doesn't report them)
I am implementing a fs, and I wasted my whole afternoon trying to figure out why
sed 300q file > mnt/data
doesn't say anything about the write error I was expecting.
Note that
sed 300q file | cat > mnt/data
shows my error message ;-)
Am I missing something?
Saludos

--
Hugo



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sed oddity
  2009-08-18 14:41 [9fans] sed oddity hugo rivera
@ 2009-08-18 14:55 ` Uriel
  2009-08-18 15:25   ` Gorka Guardiola
  2009-08-18 16:00   ` roger peppe
  2009-08-18 15:38 ` erik quanstrom
  1 sibling, 2 replies; 7+ messages in thread
From: Uriel @ 2009-08-18 14:55 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Interesting, this reminds me of a question I had: is there any command
that would read from stdin, and write to stdout, but if there was an
error when writing to stdout it would ignore it and continue reading
stdin? It is trivial to do it in C, but don't want to require an extra
program just to keep werc's error logs clean of spurious noise.

I guess based on what you said, that I might be able to use sed, but
only until your complaint is fixed :)

uriel

On Tue, Aug 18, 2009 at 4:41 PM, hugo rivera<uair00@gmail.com> wrote:
> Hi,
> is there some reason why sed doesn't check for write errors on its
> stdout? (or at least it doesn't report them)
> I am implementing a fs, and I wasted my whole afternoon trying to figure out why
> sed 300q file > mnt/data
> doesn't say anything about the write error I was expecting.
> Note that
> sed 300q file | cat > mnt/data
> shows my error message ;-)
> Am I missing something?
> Saludos
>
> --
> Hugo
>
>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sed oddity
  2009-08-18 14:55 ` Uriel
@ 2009-08-18 15:25   ` Gorka Guardiola
  2009-08-18 16:00   ` roger peppe
  1 sibling, 0 replies; 7+ messages in thread
From: Gorka Guardiola @ 2009-08-18 15:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Tue, Aug 18, 2009 at 4:55 PM, Uriel<uriel99@gmail.com> wrote:
> Interesting, this reminds me of a question I had: is there any command
> that would read from stdin, and write to stdout, but if there was an
> error when writing to stdout it would ignore it and continue reading
> stdin? It is trivial to do it in C, but don't want to require an extra
> program just to keep werc's error logs clean of spurious noise.
>
> I guess based on what you said, that I might be able to use sed, but
> only until your complaint is fixed :)
>
> uriel
>

I am not sure by your description, it looks to me like you want either:

{cat || cat > /dev/null}

or

while(;){
      cat
}

--
- curiosity sKilled the cat



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sed oddity
  2009-08-18 14:41 [9fans] sed oddity hugo rivera
  2009-08-18 14:55 ` Uriel
@ 2009-08-18 15:38 ` erik quanstrom
  2009-08-19  7:47   ` hugo rivera
  1 sibling, 1 reply; 7+ messages in thread
From: erik quanstrom @ 2009-08-18 15:38 UTC (permalink / raw)
  To: 9fans

> is there some reason why sed doesn't check for write errors on its
> stdout? (or at least it doesn't report them)

/n/sources/patch/sederrors

while i agree that sed seems more complicated that i would
like when debugging, eating errors seems like the wrong thing
to do.  it seems easy enough >[2]/dev/null if the old behavior
is wanted.

the problem was that B* functions (Bopen, Bputc, Bputrune, Bterm)
were not consistently being checked for errors.

i wonder if it would make sense to add a ->error() member
to Biobufhdr.  since most programs just want to quit if they
have a bio error, they could just quit there without needing
lots tedious error checking.

perhaps ->error could just be a boolean.

- erik



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sed oddity
  2009-08-18 14:55 ` Uriel
  2009-08-18 15:25   ` Gorka Guardiola
@ 2009-08-18 16:00   ` roger peppe
  2009-08-19 10:35     ` Uriel
  1 sibling, 1 reply; 7+ messages in thread
From: roger peppe @ 2009-08-18 16:00 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2009/8/18 Uriel <uriel99@gmail.com>:
> Interesting, this reminds me of a question I had: is there any command
> that would read from stdin, and write to stdout, but if there was an
> error when writing to stdout it would ignore it and continue reading
> stdin? It is trivial to do it in C, but don't want to require an extra
> program just to keep werc's error logs clean of spurious noise.

it seems to me that dd -conv noerror
should do what you're after, but a quick inspection
of the source shows me that i'm wrong.

i think that could be construed as a bug.

gorka's suggestion isn't quite right, i think, as
you probably do want the cat to terminate when it
reads eof or an error, so something like:

e = write
while(~ $e write*){
    cat
    e = $status
}

might do the job better (untested).



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sed oddity
  2009-08-18 15:38 ` erik quanstrom
@ 2009-08-19  7:47   ` hugo rivera
  0 siblings, 0 replies; 7+ messages in thread
From: hugo rivera @ 2009-08-19  7:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Sadly things like sed are out of my reach; I have no idea how to
program languages.
Thanks for the reply.

2009/8/18, erik quanstrom <quanstro@quanstro.net>:
> > is there some reason why sed doesn't check for write errors on its
>  > stdout? (or at least it doesn't report them)
>
>
> /n/sources/patch/sederrors
>
>  while i agree that sed seems more complicated that i would
>  like when debugging, eating errors seems like the wrong thing
>  to do.  it seems easy enough >[2]/dev/null if the old behavior
>  is wanted.
>
>  the problem was that B* functions (Bopen, Bputc, Bputrune, Bterm)
>  were not consistently being checked for errors.
>
>  i wonder if it would make sense to add a ->error() member
>  to Biobufhdr.  since most programs just want to quit if they
>  have a bio error, they could just quit there without needing
>  lots tedious error checking.
>
>  perhaps ->error could just be a boolean.
>
>
>  - erik
>
>


--
Hugo



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] sed oddity
  2009-08-18 16:00   ` roger peppe
@ 2009-08-19 10:35     ` Uriel
  0 siblings, 0 replies; 7+ messages in thread
From: Uriel @ 2009-08-19 10:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Tue, Aug 18, 2009 at 6:00 PM, roger peppe<rogpeppe@gmail.com> wrote:
> 2009/8/18 Uriel <uriel99@gmail.com>:
>> Interesting, this reminds me of a question I had: is there any command
>> that would read from stdin, and write to stdout, but if there was an
>> error when writing to stdout it would ignore it and continue reading
>> stdin? It is trivial to do it in C, but don't want to require an extra
>> program just to keep werc's error logs clean of spurious noise.
>
> it seems to me that dd -conv noerror
> should do what you're after, but a quick inspection
> of the source shows me that i'm wrong.
>
> i think that could be construed as a bug.
>
> gorka's suggestion isn't quite right, i think, as
> you probably do want the cat to terminate when it
> reads eof or an error,

Exactly.

> so something like:
>
> e = write
> while(~ $e write*){
>    cat
>    e = $status
> }
>
> might do the job better (untested).

Nice trick, will try it out, thanks!

uriel



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-08-19 10:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-18 14:41 [9fans] sed oddity hugo rivera
2009-08-18 14:55 ` Uriel
2009-08-18 15:25   ` Gorka Guardiola
2009-08-18 16:00   ` roger peppe
2009-08-19 10:35     ` Uriel
2009-08-18 15:38 ` erik quanstrom
2009-08-19  7:47   ` hugo rivera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).