9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Acme aborts on a pointless Edit command
@ 2007-12-24  4:17 Anthony Martin
  2007-12-24  4:28 ` Pietro Gagliardi
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Anthony Martin @ 2007-12-24  4:17 UTC (permalink / raw)
  To: 9fans

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-24  4:17 [9fans] Acme aborts on a pointless Edit command Anthony Martin
@ 2007-12-24  4:28 ` Pietro Gagliardi
  2007-12-24  4:37   ` Anthony Martin
  2007-12-24  9:50   ` Rob Pike
  2007-12-24  5:25 ` erik quanstrom
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 13+ messages in thread
From: Pietro Gagliardi @ 2007-12-24  4:28 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-24  4:28 ` Pietro Gagliardi
@ 2007-12-24  4:37   ` Anthony Martin
  2007-12-24  9:50   ` Rob Pike
  1 sibling, 0 replies; 13+ messages in thread
From: Anthony Martin @ 2007-12-24  4:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-24  4:17 [9fans] Acme aborts on a pointless Edit command Anthony Martin
  2007-12-24  4:28 ` Pietro Gagliardi
@ 2007-12-24  5:25 ` erik quanstrom
  2007-12-24 17:24   ` Joel C. Salomon
  2007-12-26 12:52 ` [9fans] Acme aborts on a pointless Edit command roger peppe
  2007-12-27  3:36 ` Rob Pike
  3 siblings, 1 reply; 13+ messages in thread
From: erik quanstrom @ 2007-12-24  5:25 UTC (permalink / raw)
  To: 9fans

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-24  4:28 ` Pietro Gagliardi
  2007-12-24  4:37   ` Anthony Martin
@ 2007-12-24  9:50   ` Rob Pike
  1 sibling, 0 replies; 13+ messages in thread
From: Rob Pike @ 2007-12-24  9:50 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-24  5:25 ` erik quanstrom
@ 2007-12-24 17:24   ` Joel C. Salomon
  2007-12-24 17:35     ` Pietro Gagliardi
  0 siblings, 1 reply; 13+ messages in thread
From: Joel C. Salomon @ 2007-12-24 17:24 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Dec 24, 2007 12:25 AM, erik quanstrom <quanstro@quanstro.net> 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-24 17:24   ` Joel C. Salomon
@ 2007-12-24 17:35     ` Pietro Gagliardi
  2007-12-25  1:51       ` [9fans] ipod + plan9 Philipp
  0 siblings, 1 reply; 13+ messages in thread
From: Pietro Gagliardi @ 2007-12-24 17:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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 <quanstro@quanstro.net>  
> 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [9fans] ipod + plan9
  2007-12-24 17:35     ` Pietro Gagliardi
@ 2007-12-25  1:51       ` Philipp
  2007-12-25  5:20         ` Pietro Gagliardi
  0 siblings, 1 reply; 13+ messages in thread
From: Philipp @ 2007-12-25  1:51 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] ipod + plan9
  2007-12-25  1:51       ` [9fans] ipod + plan9 Philipp
@ 2007-12-25  5:20         ` Pietro Gagliardi
  0 siblings, 0 replies; 13+ messages in thread
From: Pietro Gagliardi @ 2007-12-25  5:20 UTC (permalink / raw)
  To: 9fans

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-24  4:17 [9fans] Acme aborts on a pointless Edit command Anthony Martin
  2007-12-24  4:28 ` Pietro Gagliardi
  2007-12-24  5:25 ` erik quanstrom
@ 2007-12-26 12:52 ` roger peppe
  2007-12-26 17:52   ` ron minnich
  2007-12-27  3:36 ` Rob Pike
  3 siblings, 1 reply; 13+ messages in thread
From: roger peppe @ 2007-12-26 12:52 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Dec 24, 2007 4:17 AM, Anthony Martin <ality@pbrane.org> 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...)


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-26 12:52 ` [9fans] Acme aborts on a pointless Edit command roger peppe
@ 2007-12-26 17:52   ` ron minnich
  0 siblings, 0 replies; 13+ messages in thread
From: ron minnich @ 2007-12-26 17:52 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

:-)

ron


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
  2007-12-24  4:17 [9fans] Acme aborts on a pointless Edit command Anthony Martin
                   ` (2 preceding siblings ...)
  2007-12-26 12:52 ` [9fans] Acme aborts on a pointless Edit command roger peppe
@ 2007-12-27  3:36 ` Rob Pike
  3 siblings, 0 replies; 13+ messages in thread
From: Rob Pike @ 2007-12-27  3:36 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 23 bytes --]

Fix attached.

-rob

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 358 bytes --]

Index: ecmd.c
===================================================================
RCS file: /cvs/plan9/src/cmd/acme/ecmd.c,v
retrieving revision 1.8
diff -r1.8 ecmd.c
418a419,420
> 	}else if(addr.r.q0==addr2.r.q0 && addr.r.q1==addr2.r.q1){
> 		; /* move to self; no-op */
420c422
< 		error("move overlaps itself");
---
> 		editerror("move overlaps itself");

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [9fans] Acme aborts on a pointless Edit command
@ 2007-12-28  6:08 Joshua Wood
  0 siblings, 0 replies; 13+ messages in thread
From: Joshua Wood @ 2007-12-28  6:08 UTC (permalink / raw)
  To: 9fans

The fix builds cleanly and stops the crash described above, for me. I  
hadn't hit the bug except by contrivance, so maybe one of the  
original discussants can say if I'm missing something.

--
Josh




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-12-28  6:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-24  4:17 [9fans] Acme aborts on a pointless Edit command Anthony Martin
2007-12-24  4:28 ` Pietro Gagliardi
2007-12-24  4:37   ` Anthony Martin
2007-12-24  9:50   ` Rob Pike
2007-12-24  5:25 ` erik quanstrom
2007-12-24 17:24   ` Joel C. Salomon
2007-12-24 17:35     ` Pietro Gagliardi
2007-12-25  1:51       ` [9fans] ipod + plan9 Philipp
2007-12-25  5:20         ` Pietro Gagliardi
2007-12-26 12:52 ` [9fans] Acme aborts on a pointless Edit command roger peppe
2007-12-26 17:52   ` ron minnich
2007-12-27  3:36 ` Rob Pike
2007-12-28  6:08 Joshua Wood

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).