9front - general discussion about 9front
 help / color / mirror / Atom feed
From: tlaronde@polynum.com
To: 9front@9front.org
Subject: Re: [9front] sed: fix moving '^' match
Date: Sun, 27 Aug 2023 11:54:26 +0200	[thread overview]
Message-ID: <ZOsdUtPonBvOZ4tl@polynum.com> (raw)
In-Reply-To: <CAFSF3XO3+m3etPH1G+Cw97Qw+1+eSZbuu9Y3stcUGydWHuptrQ@mail.gmail.com>

On Sun, Aug 27, 2023 at 10:33:50AM +0200, hiro wrote:
> 
> we must be disagreeing about some fundamental understanding instead.
> it's hard for me to see still where *exactly* we differ.
> 
> just to make sure. you are aware of the other basic symmetrically
> asymmetric problems that one encounters in everyday life with sed,
> right? the asymmetry between input and output...
> 
> 
> cpu% echo aa | sed 's/aa/a/g'
> a
> cpu% echo aaaa | sed 's/aa/a/g'
> aa

Isn't this exactly a counter-example to your interpretation of the
behavior of '^aa' with "sliding" beginning (^ anchor) of the line?

To be consistent with what you interpret, "echo aaaa | sed 's/aa/a/g'"
should yield: "a"; and, in fact, all strings of more than one "a" should
give "a", since the "new" string, retaken from its new beginning, should
be reparsed.

I think the implicit understanding of 's/^..//g' is that once the first
two characters are discarded, the scanning has advanced in the original
string and hence it is not anymore at the beginning.

Ori example of the lack of symetry of behavior with 's/aa$//g' is to the
point too.

In some sense, this interpretation of 'g' is considering that 'g' makes an
infinite looping of the regex, applied to the resulting string and that should
only end if no modification is made. Seems incorrect to me.

The current behavior may be bug compatible with V8. It remains a bug
IMHO.
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

  reply	other threads:[~2023-08-27  9:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25 21:46 ori
2023-08-26  0:04 ` [9front] " Anthony Martin
2023-08-26  9:14   ` hiro
2023-08-26 17:58     ` ori
2023-08-26 18:02     ` ori
2023-08-26  9:05 ` [9front] " hiro
2023-08-26  9:41   ` ieliedonge
2023-08-26 16:48     ` hiro
2023-08-26 18:00       ` ori
2023-08-26 23:23       ` ieliedonge
2023-08-27  8:33         ` hiro
2023-08-27  9:54           ` tlaronde [this message]
2023-08-27 11:19             ` ieliedonge
2023-09-23  1:35             ` ieliedonge
2023-09-23 10:30               ` hiro
2023-09-24 15:35               ` ori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOsdUtPonBvOZ4tl@polynum.com \
    --to=tlaronde@polynum.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).