[9fans] Acme aborts on a pointless Edit command - Plan9

This is a discussion on [9fans] Acme aborts on a pointless Edit command - Plan9 ; I was feeling obscene and decided to test out stupid commands in sam and acme. Here's something I didn't expect. Sam: , x g/^/m. no change to file Acme (Edit): , x g/^/m. aborts in /sys/src/cmd/acme/ecmd.c:/^move It aborts because "move ...

+ Reply to Thread
Results 1 to 12 of 12

Thread: [9fans] Acme aborts on a pointless Edit command

  1. [9fans] Acme aborts on a pointless Edit command

    I was feeling obscene and decided to test out stupid
    commands in sam and acme. Here's something I didn't
    expect.

    Sam:
    , x g/^/m. no change to file

    Acme (Edit):
    , x g/^/m. aborts in /sys/src/cmd/acme/ecmd.c:/^move

    It aborts because "move overlaps itself" but the
    question I have is, should it work like sam and
    do *visually* nothing at all?


    Anthony

    P.S.
    This came about because I was trying to find a way to
    move lines matching a certain pattern to the beginning
    of a file (like g/pattern/m0 in ed). Is there a nice
    way to do this in sam?

    Something that works like the ed command but leaves the
    lines in original order, not reversed, would be even
    better.

    --
    I spent a night with a blow-up girl and some LSD. -Freeheat

  2. Re: [9fans] Acme aborts on a pointless Edit command

    THE UNIX PROGRAMMING ENVIRONMENT by Kernighan and Pike to the rescue!
    According to Appendix A, to reverse lines,

    g/^/m0

    Or, better yet, in rc:

    awk '
    { x[NR] = $0}
    END {
    for (i = NR; i >= 1; i--)
    print x[i]
    }'

    On Dec 23, 2007, at 11:17 PM, Anthony Martin wrote:

    > I was feeling obscene and decided to test out stupid
    > commands in sam and acme. Here's something I didn't
    > expect.
    >
    > Sam:
    > , x g/^/m. no change to file
    >
    > Acme (Edit):
    > , x g/^/m. aborts in /sys/src/cmd/acme/ecmd.c:/^move
    >
    > It aborts because "move overlaps itself" but the
    > question I have is, should it work like sam and
    > do *visually* nothing at all?
    >
    >
    > Anthony
    >
    > P.S.
    > This came about because I was trying to find a way to
    > move lines matching a certain pattern to the beginning
    > of a file (like g/pattern/m0 in ed). Is there a nice
    > way to do this in sam?
    >
    > Something that works like the ed command but leaves the
    > lines in original order, not reversed, would be even
    > better.
    >
    > --
    > I spent a night with a blow-up girl and some LSD. -Freeheat



  3. Re: [9fans] Acme aborts on a pointless Edit command

    > THE UNIX PROGRAMMING ENVIRONMENT by Kernighan and Pike to the rescue!
    > According to Appendix A, to reverse lines,
    >
    > g/^/m0


    That's how I know it. If you read again, though, you'll
    realize that wasn't my question.

    Anthony

  4. Re: [9fans] Acme aborts on a pointless Edit command

    i'd be willing to give it a pass if it whined a bit, but aborting
    on user input is a bit antisocial.

    by the way, the transliteration of the ed line reverse trick into acme
    is
    Edit ,x m$
    (with diagnostic). Edit ,x m0 does not work as expected, especially
    on the input file
    1
    2

    - erik

  5. Re: [9fans] Acme aborts on a pointless Edit command

    The command
    g/^/m0
    works in ed because the move commands are done in sequence.
    In sam and (supposedly) acme, they're done atomically, and result
    in a big no-op. They have a completely different model of execution.

    The acme problem is just a bug that should be fixed.

    -rob

  6. Re: [9fans] Acme aborts on a pointless Edit command

    On Dec 24, 2007 12:25 AM, erik quanstrom wrote:
    > i'd be willing to give it a pass if it whined a bit, but aborting
    > on user input is a bit antisocial.


    "Here I am, brain the size of a planet, and they ask me to move lines
    around and back, doing nothing. Call that job satisfaction, 'cause I
    don't. Excuse me while I go and abort()."

    --Joel

  7. Re: [9fans] Acme aborts on a pointless Edit command

    The UNIX philosophy: if something doesn't work, fix it. The code is
    available and commented to a fault.

    The DOS philosophy: if something doesn't work, get a new one or make
    one yourself. The program DEBUG is a wonderful place to start.

    The GCC philosophy: make something do simple little tasks and put it
    together in a large program with a now-pointless acronym. Oh, and
    give no warranty, and link lots and lots of useless and complicated
    libraries, and spend hours finding bugs in a single configure file.

    Choose one. Meanwhile, I'll be ed-ding /dev/sdC0/fossil to find all
    occurrences of the string "exits" and move them to where they are
    just to see ed blow up. (Seriously, you won't get far with ed-ding a
    partition - I tried).

    On Dec 24, 2007, at 12:24 PM, Joel C. Salomon wrote:

    > On Dec 24, 2007 12:25 AM, erik quanstrom
    > wrote:
    >> i'd be willing to give it a pass if it whined a bit, but aborting
    >> on user input is a bit antisocial.

    >
    > "Here I am, brain the size of a planet, and they ask me to move lines
    > around and back, doing nothing. Call that job satisfaction, 'cause I
    > don't. Excuse me while I go and abort()."
    >
    > --Joel



  8. [9fans] ipod + plan9

    hi.
    is there any tool available for accessing
    ipods (esp. nano, 3rd gen.) with plan9?
    does at least someone has tried to port libgpod2?

    phil

  9. Re: [9fans] ipod + plan9

    If it's a FAT-formatted (Windows 30GB) one, then use usbfat:
    (described in the usbfs man page). Otherwise, you'll need a port of
    ntfs-3g (Windows >30GB) or some HFS reader (Macintosh). libgpod2 is a
    start.

    On Dec 24, 2007, at 8:51 PM, Philipp wrote:

    > hi.
    > is there any tool available for accessing
    > ipods (esp. nano, 3rd gen.) with plan9?
    > does at least someone has tried to port libgpod2?
    >
    > phil



  10. Re: [9fans] Acme aborts on a pointless Edit command

    On Dec 24, 2007 4:17 AM, Anthony Martin wrote:
    > This came about because I was trying to find a way to
    > move lines matching a certain pattern to the beginning
    > of a file (like g/pattern/m0 in ed). Is there a nice
    > way to do this in sam?


    if i want to do something like this in acme, i'd tend to
    split it into stages:

    x/pattern/p
    x/pattern/d

    then paste the text in the output window back
    to the beginning of the original window.
    (actually, it would be nice if Edit output from a given
    window ended up in the local directory's +Errors window
    rather than the global one, but i've never quite mustered
    the impetus to actually do it...)

  11. Re: [9fans] Acme aborts on a pointless Edit command

    I keep waiting for the message that says "here's the patch"

    :-)

    ron

  12. Re: [9fans] Acme aborts on a pointless Edit command

    Fix attached.

    -rob


+ Reply to Thread