From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: <20071224041704.GA14349@dinah> References: <20071224041704.GA14349@dinah> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <3B5C3784-0F7A-41AA-9376-7E579254ACD4@mac.com> Content-Transfer-Encoding: 7bit From: Pietro Gagliardi Subject: Re: [9fans] Acme aborts on a pointless Edit command Date: Sun, 23 Dec 2007 23:28:16 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 21404910-ead3-11e9-9d60-3106f5b1d025 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