9front - general discussion about 9front
 help / color / mirror / Atom feed
* Re: [9front] bug in sed
@ 2019-01-12  0:52 umbraticus
  2019-01-12  0:58 ` Kurt H Maier
  0 siblings, 1 reply; 28+ messages in thread
From: umbraticus @ 2019-01-12  0:52 UTC (permalink / raw)
  To: 9front

yes, sam does it all at once, while sed iterates.

from sed(1):

                       g    Global.  Substitute for all non-
                            overlapping instances of the regular
                            expression rather than just the first one.

from ed(1):

               ... If the global replacement indi-
               cator `g' appears after the command, all subsequent
               matches on the line are also replaced...

So should "non-overlapping" and "subsequent" not apply to ^ matches?
I guess this was hiro's earlier point.


^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: [9front] bug in sed
@ 2019-01-11 23:49 umbraticus
  0 siblings, 0 replies; 28+ messages in thread
From: umbraticus @ 2019-01-11 23:49 UTC (permalink / raw)
  To: 9front

> Even if s/^ //g doesn't make sense, it should still work.  Once per line.

Yes, I agree.


^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: [9front] bug in sed
@ 2019-01-11 23:46 umbraticus
  2019-01-11 23:45 ` Kurt H Maier
  2019-01-11 23:52 ` Eckard Brauer
  0 siblings, 2 replies; 28+ messages in thread
From: umbraticus @ 2019-01-11 23:46 UTC (permalink / raw)
  To: 9front

err, to be a little clearer:

in (s)sam, g means for every match in dot,
so s/^blah//g makes sense, since dot can be multi-line

in (s)ed (yes, ed does it too), g means for every match per line,
so s/^blah//g perhaps doesn't make sense, since there is only one ^ per line...


^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: [9front] bug in sed
@ 2019-01-11 23:06 umbraticus
  2019-01-11 23:29 ` hiro
  0 siblings, 1 reply; 28+ messages in thread
From: umbraticus @ 2019-01-11 23:06 UTC (permalink / raw)
  To: 9front

> ... you need ,s instead of s at the beginning of the sam command...

ssam sets dot to the whole file before running the command.

I agree that ssam behaviour seems right and sed wrong...
^ and $ should only match once per line and don't really make sense with g.

umbraticus


^ permalink raw reply	[flat|nested] 28+ messages in thread
* [9front] bug in sed
@ 2019-01-11  5:07 Sean Hinchee
  2019-01-11  8:42 ` 有澤健治
  2019-01-11 10:55 ` Ethan Gardener
  0 siblings, 2 replies; 28+ messages in thread
From: Sean Hinchee @ 2019-01-11  5:07 UTC (permalink / raw)
  To: 9front

All,

There seems to be a bug in sed where it eats things it shouldn't:


tenshi% ed test.txt
0
a
This
   is
     a test.
Bye
.
w
26
q
tenshi% sed 's/^  //g' test.txt
This
is
a test.
Bye
tenshi% ssam 's/^  //g' test.txt
This
is
   a test.
Bye


This bug has shown up in plan9port: 
https://github.com/9fans/plan9port/issues/183

Cheers,
Sean


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

end of thread, other threads:[~2019-01-12  0:58 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-12  0:52 [9front] bug in sed umbraticus
2019-01-12  0:58 ` Kurt H Maier
  -- strict thread matches above, loose matches on Subject: below --
2019-01-11 23:49 umbraticus
2019-01-11 23:46 umbraticus
2019-01-11 23:45 ` Kurt H Maier
2019-01-11 23:52 ` Eckard Brauer
2019-01-11 23:06 umbraticus
2019-01-11 23:29 ` hiro
2019-01-11  5:07 Sean Hinchee
2019-01-11  8:42 ` 有澤健治
2019-01-11 10:20   ` hiro
2019-01-11 10:22     ` hiro
2019-01-11 10:28       ` hiro
2019-01-11 10:35         ` hiro
2019-01-11 13:04           ` 有澤健治
2019-01-11 10:32     ` 有澤健治
2019-01-11 17:49     ` Sean Hinchee
2019-01-11 19:03       ` hiro
2019-01-11 10:55 ` Ethan Gardener
2019-01-11 11:19   ` hiro
2019-01-11 11:21     ` hiro
2019-01-11 12:39       ` hiro
2019-01-11 13:10         ` Nick Owens
2019-01-11 15:01         ` Stanley Lieber
2019-01-11 15:19           ` Eckard Brauer
2019-01-11 18:30       ` Ethan Gardener
2019-01-11 19:01         ` hiro
2019-01-11 21:11           ` Xiao-Yong Jin

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