9front - general discussion about 9front
 help / color / mirror / Atom feed
* Re: [9front] sed bug?
@ 2018-11-13 19:32 umbraticus
  2018-11-13 20:04 ` Joe M
  0 siblings, 1 reply; 8+ messages in thread
From: umbraticus @ 2018-11-13 19:32 UTC (permalink / raw)
  To: 9front

> This works fine, it outputs test2
> {echo test; echo test1; echo test2} | sed '0,/^test1$/d'

really? I get: sed: line number 0 is illegal

for this one: 

>{echo test; echo test1; echo test2} | sed '1,/^test$/d' # has no output

it deletes line 1, then continues deleting lines until it finds ^test$
which it never does. Perhaps adding a newline at the start is the quickest
way to get what you want?

{echo; echo test; echo test1; echo test2} | sed '1,/^test$/d'

test1
test2

umbraticus


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

* Re: [9front] sed bug?
  2018-11-13 19:32 [9front] sed bug? umbraticus
@ 2018-11-13 20:04 ` Joe M
  2018-11-13 20:28   ` Eckard Brauer
  0 siblings, 1 reply; 8+ messages in thread
From: Joe M @ 2018-11-13 20:04 UTC (permalink / raw)
  To: 9front

Hello,

umbraticus@prosimetrum.com wrote:
> > This works fine, it outputs test2
> > {echo test; echo test1; echo test2} | sed '0,/^test1$/d'
>
> really? I get: sed: line number 0 is illegal

yes, my bad. I pasted the wrong command. It should be a 1 instead of 0.

> for this one:
>
> >{echo test; echo test1; echo test2} | sed '1,/^test$/d' # has no output
>
> it deletes line 1, then continues deleting lines until it finds ^test$
> which it never does. Perhaps adding a newline at the start is the quickest
> way to get what you want?
>
> {echo; echo test; echo test1; echo test2} | sed '1,/^test$/d'
>
> test1
> test2
>
> umbraticus

I stumbled upon the same workaround too. On a similar note, this
command works fine also:

{echo test; echo test1; echo test2} | sed '1,1d'

Thanks again


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

* Re: [9front] sed bug?
  2018-11-13 20:04 ` Joe M
@ 2018-11-13 20:28   ` Eckard Brauer
  2018-11-13 20:32     ` Dave MacFarlane
  2018-11-13 20:43     ` Antons Suspans
  0 siblings, 2 replies; 8+ messages in thread
From: Eckard Brauer @ 2018-11-13 20:28 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]

At least it look inconsistent:

% {echo test; echo test1; echo test2;echo test3} | sed '1,/^test$/d'
% {echo test; echo test1; echo test2;echo test3} | sed '1,/^test1$/d'
test2
test3
% {echo test; echo test1; echo test2;echo test3} | sed '1,/^test2$/d'
test3

seems search starts just after addressed line (1 in this case): in fist
case nothing is found, so search goes until end, then mothing remains
for output.

as the man page states:

	[address [, address] ] function [argument ...]

as valid, "1/test$/d' should work, but it seems not to be the case:

% {echo test; echo test1; echo test2;echo test3} | sed '1/^test$/d'
sed: Unrecognized command: 1/^test$/d

BTW, GNU sed (Linux) seems to behave similar.

Am Tue, 13 Nov 2018 13:04:01 -0700
schrieb Joe M <joe9mail@gmail.com>:

> Hello,
> 
> umbraticus@prosimetrum.com wrote:
>  [...]  
>  [...]  
> 
> yes, my bad. I pasted the wrong command. It should be a 1 instead of
> 0.
> 
>  [...]  
>  [...]  
>  [...]  
> 
> I stumbled upon the same workaround too. On a similar note, this
> command works fine also:
> 
> {echo test; echo test1; echo test2} | sed '1,1d'
> 
> Thanks again



-- 
:)

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [9front] sed bug?
  2018-11-13 20:28   ` Eckard Brauer
@ 2018-11-13 20:32     ` Dave MacFarlane
  2018-11-13 20:55       ` Eckard Brauer
  2018-11-13 20:43     ` Antons Suspans
  1 sibling, 1 reply; 8+ messages in thread
From: Dave MacFarlane @ 2018-11-13 20:32 UTC (permalink / raw)
  To: 9front mailing list

"1/test$/d" doesn't match the pattern "[address [, address] ] function
[argument ...]". There's a comma that separates the two addresses in
the documentation.
On Tue, Nov 13, 2018 at 3:28 PM Eckard Brauer <eckard.brauer@gmx.de> wrote:
>
> At least it look inconsistent:
>
> % {echo test; echo test1; echo test2;echo test3} | sed '1,/^test$/d'
> % {echo test; echo test1; echo test2;echo test3} | sed '1,/^test1$/d'
> test2
> test3
> % {echo test; echo test1; echo test2;echo test3} | sed '1,/^test2$/d'
> test3
>
> seems search starts just after addressed line (1 in this case): in fist
> case nothing is found, so search goes until end, then mothing remains
> for output.
>
> as the man page states:
>
>         [address [, address] ] function [argument ...]
>
> as valid, "1/test$/d' should work, but it seems not to be the case:
>
> % {echo test; echo test1; echo test2;echo test3} | sed '1/^test$/d'
> sed: Unrecognized command: 1/^test$/d
>
> BTW, GNU sed (Linux) seems to behave similar.
>
> Am Tue, 13 Nov 2018 13:04:01 -0700
> schrieb Joe M <joe9mail@gmail.com>:
>
> > Hello,
> >
> > umbraticus@prosimetrum.com wrote:
> >  [...]
> >  [...]
> >
> > yes, my bad. I pasted the wrong command. It should be a 1 instead of
> > 0.
> >
> >  [...]
> >  [...]
> >  [...]
> >
> > I stumbled upon the same workaround too. On a similar note, this
> > command works fine also:
> >
> > {echo test; echo test1; echo test2} | sed '1,1d'
> >
> > Thanks again
>
>
>
> --
> :)



-- 
- Dave


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

* Re: [9front] sed bug?
  2018-11-13 20:28   ` Eckard Brauer
  2018-11-13 20:32     ` Dave MacFarlane
@ 2018-11-13 20:43     ` Antons Suspans
  2018-11-13 21:07       ` Eckard Brauer
  1 sibling, 1 reply; 8+ messages in thread
From: Antons Suspans @ 2018-11-13 20:43 UTC (permalink / raw)
  To: 9front

On Tue, Nov 13, 2018 at 09:28:06PM +0100, Eckard Brauer wrote:
> BTW, GNU sed (Linux) seems to behave similar.

The man page of GNU sed describes this behavior explicitly:

"if addr2 is a regexp, it will not be tested against the line that addr1 matched"

(Man pages of Plan 9 are typically less tormenting.)


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

* Re: [9front] sed bug?
  2018-11-13 20:32     ` Dave MacFarlane
@ 2018-11-13 20:55       ` Eckard Brauer
  0 siblings, 0 replies; 8+ messages in thread
From: Eckard Brauer @ 2018-11-13 20:55 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 618 bytes --]

You're right, as the result of the search is an address.

But in that case, 1,/pattern/ applies the function d to the first line,
as 1,<address> evaluates to 1,1. So it points out to be a bug in sed
(even in GNU sed).

Am Tue, 13 Nov 2018 15:32:12 -0500
schrieb Dave MacFarlane <driusan@gmail.com>:

> "1/test$/d" doesn't match the pattern "[address [, address] ] function
> [argument ...]". There's a comma that separates the two addresses in
> the documentation.
> On Tue, Nov 13, 2018 at 3:28 PM Eckard Brauer <eckard.brauer@gmx.de>
> wrote: [...]  
>  [...]  
>  [...]  
> 
> 
> 



-- 
:)

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [9front] sed bug?
  2018-11-13 20:43     ` Antons Suspans
@ 2018-11-13 21:07       ` Eckard Brauer
  2018-11-13 21:09         ` Eckard Brauer
  0 siblings, 1 reply; 8+ messages in thread
From: Eckard Brauer @ 2018-11-13 21:07 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

What does that mean, and where does the regexp apply? This had to be
documented, as the case shows.

Either ther regexp applies beginning the line from addr1 (what I'd
treat as the expected behaviour), we have a bug in *sed, or the pattern
applies from the line /following/ addr1, then it had to be clearly
documented, what isn't the case.



Am Tue, 13 Nov 2018 22:43:54 +0200
schrieb Antons Suspans <antox@ml.lv>:

> On Tue, Nov 13, 2018 at 09:28:06PM +0100, Eckard Brauer wrote:
>  [...]  
> 
> The man page of GNU sed describes this behavior explicitly:
> 
> "if addr2 is a regexp, it will not be tested against the line that
> addr1 matched"
> 
> (Man pages of Plan 9 are typically less tormenting.)



-- 
:)

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [9front] sed bug?
  2018-11-13 21:07       ` Eckard Brauer
@ 2018-11-13 21:09         ` Eckard Brauer
  0 siblings, 0 replies; 8+ messages in thread
From: Eckard Brauer @ 2018-11-13 21:09 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

OK, got it just when reading again. Please ignore preceding mail.

Am Tue, 13 Nov 2018 22:07:15 +0100
schrieb Eckard Brauer <eckard.brauer@gmx.de>:

> What does that mean, and where does the regexp apply? This had to be
> documented, as the case shows.
> 
> Either ther regexp applies beginning the line from addr1 (what I'd
> treat as the expected behaviour), we have a bug in *sed, or the
> pattern applies from the line /following/ addr1, then it had to be
> clearly documented, what isn't the case.
> 
> 
> 
> Am Tue, 13 Nov 2018 22:43:54 +0200
> schrieb Antons Suspans <antox@ml.lv>:
> 
>  [...]  
> 
> 
> 



-- 
:)

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2018-11-13 21:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 19:32 [9front] sed bug? umbraticus
2018-11-13 20:04 ` Joe M
2018-11-13 20:28   ` Eckard Brauer
2018-11-13 20:32     ` Dave MacFarlane
2018-11-13 20:55       ` Eckard Brauer
2018-11-13 20:43     ` Antons Suspans
2018-11-13 21:07       ` Eckard Brauer
2018-11-13 21:09         ` Eckard Brauer

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