sed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "sed --debug" feature


From: Jim Meyering
Subject: Re: "sed --debug" feature
Date: Fri, 27 Jul 2018 15:13:09 -0700

Nice work. Will use :-)

On Fri, Jul 27, 2018, 03:29 Assaf Gordon <address@hidden> wrote:

> Hi all,
>
> While investigating the two recent bugs [1][2],
> I developed some debugging code for sed, which makes
> troubleshooting much easier.
>
> [1] https://lists.gnu.org/r/bug-sed/2018-07/msg00004.html
> [2] https://lists.gnu.org/r/bug-sed/2018-07/msg00018.html
>
> First,
> It turns cryptic code into more readable sed code:
>
>    $ cat bug32271.sed
>    s0^004
>    s5505
>    s5505
>    s5505
>    s5505
>    N
>    W0
>    s5$55M
>    s55550
>    s55550
>    s5555
>    D
>
>    $ ./sed/sed --debug -f bug32271.sed
>    SED PROGRAM:
>    s/^//4
>    s//0/
>    s//0/
>    s//0/
>    s//0/
>    N
>    W0
>    s/$//m
>    s///50
>    s///50
>    s///5
>    D
>
> and
>
>    $ cat bug32082.sed
>    10s11\91
>    \0^0s1011
>    \00a
>    \0^0s111w0
>
>    $ ./sed/sed --debug -f bug32082.sed
>    SED PROGRAM:
>    10 s//\9/
>    /^/ s/0//
>    // a\
>
>    /^/ s///w0
>
>
>
> Second, it also traces step-by-step each command
> while printing the pattern/hold buffers:
>
>    $ seq 5 | sed --debug 'N;s/3/X/'
>    SED PROGRAM:
>    N
>    s/3/X/
>    INPUT:   STDIN line 1
>    PATTERN: 1
>    COMMAND: N
>    PATTERN: 1\n2
>    COMMAND: s/3/X/
>    PATTERN: 1\n2
>    END-OF-CYCLE:
>    1
>    2
>    INPUT:   STDIN line 3
>    PATTERN: 3
>    COMMAND: N
>    PATTERN: 3\n4
>    COMMAND: s/3/X/
>    PATTERN: X\n4
>    END-OF-CYCLE:
>    X
>    4
>    INPUT:   STDIN line 5
>    PATTERN: 5
>    COMMAND: N
>    END-OF-CYCLE:
>    5
>
>
> I'm not sure this should go into mainline sed (too specialized and
> border-line bloat), but I thought to share it here for future reference.
>
> comments welcomed,
>   - assaf
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]