9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Re: \n\n\n to \n\n
@ 2003-03-05 15:12 peter a. cejchan
  2003-03-05 19:20 ` Fco.J.Ballesteros
  0 siblings, 1 reply; 8+ messages in thread
From: peter a. cejchan @ 2003-03-05 15:12 UTC (permalink / raw)
  To: 9fans

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

>  And of course you can always wrap sam in a script just to
>  pretend that you have ssam.

could someone show me , how?

sorry for ignorance,
++pac

[-- Attachment #2: Type: text/html, Size: 711 bytes --]

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

* Re: [9fans] Re: \n\n\n to \n\n
  2003-03-05 15:12 [9fans] Re: \n\n\n to \n\n peter a. cejchan
@ 2003-03-05 19:20 ` Fco.J.Ballesteros
  0 siblings, 0 replies; 8+ messages in thread
From: Fco.J.Ballesteros @ 2003-03-05 19:20 UTC (permalink / raw)
  To: 9fans

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

This is naive and dirty but it's what I use:

I pass different `command lines' to sam by using different
arguments. It can be done better for sure but I didn't bother.

hth

#!/bin/rc
t=/tmp/ssam.$pid

fn exit () {
	rm -f $t
}
cat > $t
{
	for (c in $*)	echo $c	
	echo q
} | sam -d $t >[2] /dev/null
rm -f $t


[-- Attachment #2: Type: message/rfc822, Size: 2854 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 157 bytes --]

>  And of course you can always wrap sam in a script just to
>  pretend that you have ssam.

could someone show me , how?

sorry for ignorance,
++pac

[-- Attachment #2.1.2: Type: text/html, Size: 711 bytes --]

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

* Re: [9fans] Re: \n\n\n to \n\n
  2003-03-07 11:14 ` Douglas A. Gwyn
@ 2003-03-07 12:34   ` Fco.J.Ballesteros
  0 siblings, 0 replies; 8+ messages in thread
From: Fco.J.Ballesteros @ 2003-03-07 12:34 UTC (permalink / raw)
  To: 9fans

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

I using all of Edit, sed, ssam. Depending on the kind of task
I use one or another. So, let's not forget Edit :-)

[-- Attachment #2: Type: message/rfc822, Size: 1769 bytes --]

From: "Douglas A. Gwyn" <DAGwyn@null.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Re: \n\n\n to \n\n
Date: Fri, 7 Mar 2003 11:14:05 GMT
Message-ID: <3E67E3AD.1010209@null.net>

peter a. cejchan wrote:
> PS: I'm going to test the posted wrappers to Sam, and then, hopefully, 
> forget of Edit, and |sed   ;-)

The main advantage of sed is that it can process in a truly
streaming fashion, whereas sam, ed, etc. all have to see the
end of file on the input before any editing can be done to
the file.

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

* Re: [9fans] Re: \n\n\n to \n\n
  2003-03-06  6:25 peter a. cejchan
@ 2003-03-07 11:14 ` Douglas A. Gwyn
  2003-03-07 12:34   ` Fco.J.Ballesteros
  0 siblings, 1 reply; 8+ messages in thread
From: Douglas A. Gwyn @ 2003-03-07 11:14 UTC (permalink / raw)
  To: 9fans

peter a. cejchan wrote:
> PS: I'm going to test the posted wrappers to Sam, and then, hopefully, 
> forget of Edit, and |sed   ;-)

The main advantage of sed is that it can process in a truly
streaming fashion, whereas sam, ed, etc. all have to see the
end of file on the input before any editing can be done to
the file.


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

* [9fans] Re: \n\n\n to \n\n
@ 2003-03-06  6:25 peter a. cejchan
  2003-03-07 11:14 ` Douglas A. Gwyn
  0 siblings, 1 reply; 8+ messages in thread
From: peter a. cejchan @ 2003-03-06  6:25 UTC (permalink / raw)
  To: 9fans

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

>> I just wonder why Edit is a built-in... I would prefer piping to (streamed) sam...
>> wouldn't that be a cleaner solution?

>  First, there isn't a streamed sam, and second, streaming only works
>  for one file.  Second, you *can* stream text through commands; I do it
>  all the time.  (|fmt, |sort, |tr A-Z a-z, etc.  etc.)

So do I. I was just curious why there is a built-in Edit instead of having "a better sed" ... I thought of Acme
as of an environment (say, glue), not a text teditor. Would love to have Plan 9 like a "LEGO" (TM), and more: single 
piece for every "task".... maybe stupid, but I would love sed with capabilities of Edit...

PS: I'm going to test the posted wrappers to Sam, and then, hopefully, forget of Edit, and |sed   ;-)
++pac

[-- Attachment #2: Type: text/html, Size: 1474 bytes --]

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

* Re: [9fans] Re: \n\n\n to \n\n
@ 2003-03-05 18:05 rog
  0 siblings, 0 replies; 8+ messages in thread
From: rog @ 2003-03-05 18:05 UTC (permalink / raw)
  To: 9fans

> >  And of course you can always wrap sam in a script just to
> >  pretend that you have ssam.
>
> could someone show me , how?

the following script does something of the sort; if you were prepared
to go without error messages, you could dispense with the clunky sed
script.

unfortunately it produces output even if there's an error in the
script.  i don't know if there's anything that can be done about
that...

use like:

	echo hello | ssam ',x/l/c/x/'

it's only had 'presotto' testing...

#!/bin/rc
{
	{
		for (i) echo $i
		echo w /fd/1
	} |
	sam -d /fd/3 |[2]
	sed -e '/^\?changed files/d' -e '/^[^?]/d'  -e 's/\?/ssam: /' >[1=2]
} <[3=0]



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

* Re: [9fans] Re: \n\n\n to \n\n
  2003-03-05  6:52 peter a. cejchan
@ 2003-03-05 17:26 ` rob pike, esq.
  0 siblings, 0 replies; 8+ messages in thread
From: rob pike, esq. @ 2003-03-05 17:26 UTC (permalink / raw)
  To: 9fans

> I just wonder why Edit is a built-in... I would prefer piping to (streamed) sam...
> wouldn't that be a cleaner solution?

First, there isn't a streamed sam, and second, streaming only works
for one file.  Second, you *can* stream text through commands; I do it
all the time.  (|fmt, |sort, |tr A-Z a-z, etc.  etc.)

But to answer your question: I find the X command extremely powerful,
and can't see any way to have a streaming implementation that will
look at multiple files simultaneously.

One day I realized I could easily implement Edit as a command in acme,
but that after about fifteen years of desultory thought I still didn't
see the right way to build a stream sam.  The X command was the
clincher, and I started hacking.

-rob



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

* [9fans] Re: \n\n\n to \n\n
@ 2003-03-05  6:52 peter a. cejchan
  2003-03-05 17:26 ` rob pike, esq.
  0 siblings, 1 reply; 8+ messages in thread
From: peter a. cejchan @ 2003-03-05  6:52 UTC (permalink / raw)
  To: 9fans

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

> however, sed doesn't like long lines 
> you could do it in sam: s/\n\n\n/\n\n/g

finally, i did it using acme's Edit. Thanks!


I just wonder why Edit is a built-in... I would prefer piping to (streamed) sam...
wouldn't that be a cleaner solution? One of the things I love on unix/plan 9 is their modularity, thus,
why to have a standalone webbrowser when there is acme + hget + gif (page),
likewise with mail,
and why to have a built-in Edit when there is acme + sed (ssam, awk, perl....)?
Or am I missing something?

Thanks,
++pac

[-- Attachment #2: Type: text/html, Size: 1288 bytes --]

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

end of thread, other threads:[~2003-03-07 12:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-05 15:12 [9fans] Re: \n\n\n to \n\n peter a. cejchan
2003-03-05 19:20 ` Fco.J.Ballesteros
  -- strict thread matches above, loose matches on Subject: below --
2003-03-06  6:25 peter a. cejchan
2003-03-07 11:14 ` Douglas A. Gwyn
2003-03-07 12:34   ` Fco.J.Ballesteros
2003-03-05 18:05 rog
2003-03-05  6:52 peter a. cejchan
2003-03-05 17:26 ` rob pike, esq.

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