• ed in linux?

    From Siri Cruise@21:1/5 to All on Sat Feb 19 03:40:41 2022
    I want to conditionally edit a file in a makefile: if the file
    has 'xyzzy' the file should not be changed. The make action is
    akin to

    (echo 'g/xyzzy/q'; \
    echo 'more ed commands' \
    echo ... \
    echo wq) | ed file

    On macosx, this works as expected: if the 'xyzzy' is anywhere in
    the file, ed quits on the first command, the file is unchanged,
    ed exit code is 0 and make continues.

    On linux, the g fails (prints ?) and ed exits with a failure exit
    code.

    Does anyone have a suggestion so linux ed act like macos ed?


    ob-irrlevqnt-rage-at-the-sky f*** this dying jeyboard!!!

    --
    :-<> Siri Seal of Disavowal #000-001. Disavowed. Denied. Deleted. @
    'I desire mercy, not sacrifice.' /|\ Discordia: not just a religion but also a parody. This post / \
    I am an Andrea Doria sockpuppet. insults Islam. Mohammed

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Siri Cruise on Sat Feb 19 17:44:39 2022
    Siri Cruise <[email protected]> writes:

    I want to conditionally edit a file in a makefile: if the file
    has 'xyzzy' the file should not be changed. The make action is
    akin to

    (echo 'g/xyzzy/q'; \
    echo 'more ed commands' \
    echo ... \
    echo wq) | ed file

    It's the ;. This works for me:

    (echo 'g/xyzzy/q
    another cmd
    and another
    w
    q
    ') | ed file

    But I'd consider some other way myself. Something like

    grep -q xyzzy file || some other command to edit the file

    BTW,

    printf "%s\n" l1 l2 l3 | ed file

    is a simple way to get the newlines.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Siri Cruise@21:1/5 to Ben Bacarisse on Sat Feb 19 11:32:08 2022
    In article <[email protected]>,
    Ben Bacarisse <[email protected]> wrote:

    Siri Cruise <[email protected]> writes:

    I want to conditionally edit a file in a makefile: if the file
    has 'xyzzy' the file should not be changed. The make action is
    akin to

    (echo 'g/xyzzy/q'; \
    echo 'more ed commands' \
    echo ... \
    echo wq) | ed file

    It's the ;. This works for me:

    (echo 'g/xyzzy/q
    another cmd
    and another
    w
    q
    ') | ed file

    But I'd consider some other way myself. Something like

    grep -q xyzzy file || some other command to edit the file

    That requires hunting down the makefile segments and driving
    stqkes through their hearts, which I hoped to void.

    'You Americans. You make everything so simple so complicated.'

    --
    :-<> Siri Seal of Disavowal #000-001. Disavowed. Denied. Deleted. @
    'I desire mercy, not sacrifice.' /|\ Discordia: not just a religion but also a parody. This post / \
    I am an Andrea Doria sockpuppet. insults Islam. Mohammed

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Siri Cruise on Sat Feb 19 20:46:17 2022
    Siri Cruise <[email protected]> writes:

    In article <[email protected]>,
    Ben Bacarisse <[email protected]> wrote:

    Siri Cruise <[email protected]> writes:

    I want to conditionally edit a file in a makefile: if the file
    has 'xyzzy' the file should not be changed. The make action is
    akin to

    (echo 'g/xyzzy/q'; \
    echo 'more ed commands' \
    echo ... \
    echo wq) | ed file

    It's the ;. This works for me:

    (echo 'g/xyzzy/q
    another cmd
    and another
    w
    q
    ') | ed file

    But I'd consider some other way myself. Something like

    grep -q xyzzy file || some other command to edit the file

    That requires hunting down the makefile segments and driving
    stqkes through their hearts, which I hoped to void.

    You were looking for a way to make Linux ed support a different command
    syntax? I think you are out of luck with that.

    'You Americans. You make everything so simple so complicated.'

    What have Americans got to do with the price of fish? Did an American
    write the makefile? Piping to ed has long been considered an
    anti-pattern.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric Pozharski@21:1/5 to Ben Bacarisse on Mon Feb 21 08:19:25 2022
    with <[email protected]> Ben Bacarisse wrote:
    Siri Cruise <[email protected]> writes:

    I want to conditionally edit a file in a makefile: if the file has
    'xyzzy' the file should not be changed. The make action is akin to

    (echo 'g/xyzzy/q'; \
    echo 'more ed commands' \
    echo ... \
    echo wq) | ed file

    It's the ;. This works for me:

    Let me stir into this higly intellectual discussion. Here comes:

    This is fscked up on so many levels.

    ben.usenet@, whatever you're doing works for you because you're running
    same ed(1) as that of macos. chine.bleu@ has no problems with BSD ed,
    they have problems with GNU ed. See where it's going?

    chine.bleu@, GNU ed doesn't do any command suffixes except those that
    print (namely, 'l', 'p', 'n') (because, "Just because?", I guess).
    Second, neither of you copy-paste -- neither your commands nor your
    files. Is it too much to ask for The Complete Minimal Example? One
    might only wonder what are reasons behind first escaping newlines, then breaking this (effectevely) single-line with semicolons.

    *SKIP*

    --
    Torvalds' goal for Linux is very simple: World Domination
    Stallman's goal for GNU is even simpler: Freedom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Siri Cruise on Wed Feb 23 16:49:56 2022
    Siri Cruise <[email protected]> writes:
    In article <[email protected]et>,
    Eric Pozharski <[email protected]> wrote:

    chine.bleu@, GNU ed doesn't do any command suffixes except those that
    print (namely, 'l', 'p', 'n') (because, "Just because?", I guess).

    By command suffix you mean the '...' in 'g/re/...', correct?

    [expletive deleted]. My alternative has been tclsh to read the
    file, modify it with regsub etc, and write it back. I guess I'll
    have to do that from now. ed doesn't do much, but it was easy to
    invoke and I assumed would be universally equivalent on all
    unices.

    All versions of ed should support what is defined here:

    https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ed.html

    Have you investigated sed or awk as an alternative?

    Specifically, note for the global command that Posix says:

    "The use of the g, G, v, V, and ! commands in the command
    list produces undefined results"

    This is likely because the various flavors of ed(1) in existance
    when the standard was written did not all handle those commmands
    in the same way.

    Note that the gnu ed(1) manpage explicitly states that those
    commands are not allowed as part of the global command-list.

    Any commands are allowed, except for 'g', 'G', 'v', and 'V'. By
    default, a newline alone in COMMAND-LIST is equivalent to a 'p'
    command.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Siri Cruise@21:1/5 to Eric Pozharski on Wed Feb 23 08:19:05 2022
    In article <[email protected]et>,
    Eric Pozharski <[email protected]> wrote:

    chine.bleu@, GNU ed doesn't do any command suffixes except those that
    print (namely, 'l', 'p', 'n') (because, "Just because?", I guess).

    By command suffix you mean the '...' in 'g/re/...', correct?

    [expletive deleted]. My alternative has been tclsh to read the
    file, modify it with regsub etc, and write it back. I guess I'll
    have to do that from now. ed doesn't do much, but it was easy to
    invoke and I assumed would be universally equivalent on all
    unices.

    --
    :-<> Siri Seal of Disavowal #000-001. Disavowed. Denied. Deleted. @
    'I desire mercy, not sacrifice.' /|\ Discordia: not just a religion but also a parody. This post / \
    I am an Andrea Doria sockpuppet. insults Islam. Mohammed

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Wed Feb 23 18:54:51 2022
    * Siri Cruise <[email protected]>
    | In article <[email protected]et>,
    | Eric Pozharski <[email protected]> wrote:

    | > chine.bleu@, GNU ed doesn't do any command suffixes except those that
    | > print (namely, 'l', 'p', 'n') (because, "Just because?", I guess).

    | By command suffix you mean the '...' in 'g/re/...', correct?

    | [expletive deleted]. My alternative has been tclsh to read the
    | file, modify it with regsub etc, and write it back. I guess I'll
    | have to do that from now. ed doesn't do much, but it was easy to
    | invoke and I assumed would be universally equivalent on all unices.

    *headscratch* What's wrong with 'sed'? Though I don't know if that
    suffers the same deficiencies between platforms as 'ed'...

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to [email protected] on Wed Feb 23 18:59:17 2022
    In article <[email protected]>, Ralf Fassel <[email protected]> wrote: >* Siri Cruise <[email protected]>
    | In article <[email protected]et>,
    | Eric Pozharski <[email protected]> wrote:

    | > chine.bleu@, GNU ed doesn't do any command suffixes except those that
    | > print (namely, 'l', 'p', 'n') (because, "Just because?", I guess).

    | By command suffix you mean the '...' in 'g/re/...', correct?

    | [expletive deleted]. My alternative has been tclsh to read the
    | file, modify it with regsub etc, and write it back. I guess I'll
    | have to do that from now. ed doesn't do much, but it was easy to
    | invoke and I assumed would be universally equivalent on all unices.

    *headscratch* What's wrong with 'sed'? Though I don't know if that
    suffers the same deficiencies between platforms as 'ed'...

    sed is just so ... weird.

    Most sensible people recommend against using sed for anything other than
    simple s/foo/bar/g usage. Once you get past that, things just start
    getting weird.

    Also, yes, I'm sure there's variation across platforms. Most people will
    be used to the GNU version (of sed or anything else) and get used to using
    GNU extensions, which leads to, well, you know...

    In particular, one nice thing about using a real editor (such as "ed") in a batch/scripted way (as opposed to using something more batch/script
    oriented like "sed") is that it natively edits in place. That is, you
    script it, and it writes back to the original file by default. With sed
    and other batch/script oriented tools, you have to hem and haw to get "in place" editing. (Yes, I know that it is a feature of GNU sed - thus, see previous paragraph).

    --
    The randomly chosen signature file that would have appeared here is more than 4 lines long. As such, it violates one or more Usenet RFCs. In order to remain in compliance with said RFCs, the actual sig can be found at the following URL:
    http://user.xmission.com/~gazelle/Sigs/DanaC

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric Pozharski@21:1/5 to Siri Cruise on Thu Feb 24 10:16:52 2022
    with <[email protected]>
    Siri Cruise wrote:
    In article <[email protected]et>, Eric Pozharski <[email protected]> wrote:

    chine.bleu@, GNU ed doesn't do any command suffixes except those that
    print (namely, 'l', 'p', 'n') (because, "Just because?", I guess).
    By command suffix you mean the '...' in 'g/re/...', correct?

    Wrong. *I* was wrong. Indeed, "suffixes" are for anything but 'g' brotherhood. For those four it's "command-list". Still, 'q' is
    *rejected* for unspecified reasons:

    [0:0]% cat ~/foo.s6ckUi.txt
    foo
    bar
    [0:0]% ed !$
    ed ~/foo.s6ckUi.txt
    8
    H
    g/foo/q
    ?

    %n
    1 foo
    2 bar
    q

    [expletive deleted]. My alternative has been tclsh to read the file,
    modify it with regsub etc, and write it back. I guess I'll have to do
    that from now. ed doesn't do much, but it was easy to invoke and I
    assumed would be universally equivalent on all unices.

    In last 12 month I've went through sources of pdns-recursor, dcron
    (fscking vaporware), pppd, comgt, perl, and zsh. I don't know what are
    you talking about and I'm not interested. I'm burnt out. I'm glad you realized the dead-end early enough.

    --
    Torvalds' goal for Linux is very simple: World Domination
    Stallman's goal for GNU is even simpler: Freedom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to All on Thu Feb 24 14:12:09 2022
    In last 12 month I've went through sources of pdns-recursor, dcron
    (fscking vaporware),

    I'm curious. Can you elaborate on "dcron (fscking vaporware)"?

    pppd, comgt, perl, and zsh. I don't know what are
    you talking about and I'm not interested. I'm burnt out. I'm glad you realized the dead-end early enough.

    Just eavesdripping ;-)
    --
    Lew Pitcher
    "In Skills, We Trust"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric Pozharski@21:1/5 to Lew Pitcher on Fri Feb 25 14:24:30 2022
    with <sv83np$lbf$[email protected]> Lew Pitcher wrote:

    In last 12 month I've went through sources of pdns-recursor, dcron
    (fscking vaporware),
    I'm curious. Can you elaborate on "dcron (fscking vaporware)"?

    So, I need anacron themed functionality. I've fantasized about doing it without anacron itself. Alegedly, dcron has ID=, AFTER=, EAGAIN, and
    FREQ= -- thus, I have all building blocks I need. Or so I thought.

    I dont't have distinct memory if AFTER= works ((probably it does),
    problem is I've not reached that far because:

    * EAGAIN works *only* if logging is at level DEBUG. Otherwise, errno=11
    is treated like any other not null.

    * FREQ= doesn't work at all. Like, it's illigal syntax.

    Upon inspecting sources, I've discovered about 2/3 of EAGAIN code is
    commented out. All about FREQ= code is commented out.

    Otherwise, as minimal crond dcron is fine. I was so close.

    pppd, comgt, perl, and zsh. I don't know what are you talking about
    and I'm not interested. I'm burnt out. I'm glad you realized the
    dead-end early enough.
    Just eavesdripping ;-)

    Funny thing, comgt works indeed. Docu is so terrible, I just don't know
    what to expect.

    --
    Torvalds' goal for Linux is very simple: World Domination
    Stallman's goal for GNU is even simpler: Freedom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)