Re: [9fans] p9p sed vs linux sed

2015-08-12 Thread Ingo Krabbe


 | sed 's/^//' | sed 's/$//'
 

Why would you pipe text data in acme through sed and not use

Edit x/^.*$/s/.*//

?





Re: [9fans] p9p sed vs linux sed

2015-08-12 Thread Rudolf Sykora
On 12 August 2015 at 15:47,  lu...@proxima.alt.za wrote:
 You can't write a file in vi that does not end in a newline.

You, however, can do it pretty easily with cat.
(Sam asks you if you mean it, acme just does it.)

 So, I vote that text handling utilities should deal with all lines in
 text files uniformly,even the last one.

I encountered the problem when I selected a couple of words in acme
which I wanted to bracket with sed with something like

| sed 's/^//' | sed 's/$//'

and suddenly you see...

On the other hand, as you say, it's a matter of taste.
(If the behaviour is not prescribed.)

R Sykora



Re: [9fans] Small Plan 9 Platforms

2015-08-12 Thread Brian L. Stuart
On Wed, 8/12/15, Skip Tavakkolian 9...@9netics.com wrote:
 the gpio pins don't seem accessible through a filesystem api
 like i see in plan9-bcm (unless i've missed something).

I'm pretty sure it's not there.

  it would be great to merge that capability in.

I've made a start on that this afternoon.  I took the devbcm from
plan9-bcm and stripped it down to just the gpio parts and
renamed it devgpio.  I've now got a B+ running with Richard's
latest code that includes I2C and SPI and a first cut revision of
devgpio.  I'm watching an LED I wired up to it blinking driven
by a program in user space as I type this.

BLS
 
 




Re: [9fans] Small Plan 9 Platforms

2015-08-12 Thread Skip Tavakkolian
 On Wed, 8/12/15, David du Colombier 0in...@gmail.com wrote:
  Is all that on sources somewhere or accessible otherwise?
 
 Richard's latest Raspberry Pi repository is available here:
 
 /n/sources/contrib/miller/9/bcm
 
 Cool.  Somehow I missed that.  I'll pull it and play with it.  Using
 the github plan9-bcm devbcm, I've gotten as far as blinking an
 LED, but if there's already working I2C and SPI code, I've got
 devices that need to talk that.
 
 Thanks,
 BLS

a little update: i am running Richard's latest bcm on several rpi's. i'm using
the ds3231 based rtc (link below) on a couple of them. these use the i2c;
everything is working as expected.

the gpio pins don't seem accessible through a filesystem api like i see in
plan9-bcm (unless i've missed something).  it would be great to merge
that capability in.

http://www.ebay.com/itm/DS3231-Precision-RTC-Module-Memory-Module-for-Raspberry-Pi-/181405526368?hash=item2a3c9ca960




Re: [9fans] p9p sed vs linux sed

2015-08-12 Thread Ingo Krabbe
You mean perseus=; is your prompt? Strange.

Actually sed is a line based command and should add a newline, imho. You can 
simply use tr -d '\n'.

There are several quoting differences between plan9 sed and linux sed and I 
think the \+ operator doesn't work anyway in linux sed, but I might be wrong 
with this statement.

cheers,
ingo

 Hello,
 
 is this as expected?
 
 perseus=; echo -n aaa | 9 sed 's/^//' |tr -d '\n'
 aaa
 perseus=; echo -n aaa | sed 's/^//'
 aaaperseus=;
 
 
 For me the linux sed does what I expect,
 but not the p9p one (it adds a newline). Why?
 
 Thanks!
 Ruda





Re: [9fans] p9p sed vs linux sed

2015-08-12 Thread Rudolf Sykora
 From the POSIX description (used here as some reference), when a
 line is entered in the pattern space, the trailing new line is
 discarded. When the pattern space is written to stdout it seems
 that implicitely the new line is restored---the POSIX description
 says that the input shall be a text file; and ISTR that with an
 editor, a newline is entered to the last line because a text file
 is considered to be an array of newline terminated lines.

 This means that it is a grey zone and depends on things that are not all
 explicitely stated and that the p9 sed(1) is not, from the/some
 specification, at fault.

Thanks for some explanation!
I now understand a bit more.
It's a pity, anyhow.

Ruda



Re: [9fans] read9pmsg usage

2015-08-12 Thread David du Colombier
 Ah, if only git existed when that comment was written! :-D

This comment is indeed pretty old. It was already present
in the Second Edition.

-- 
David du Colombier



Re: [9fans] p9p sed vs linux sed

2015-08-12 Thread Rudolf Sykora
On 12 August 2015 at 09:48, Ingo Krabbe ikrabbe@gmail.com wrote:
 You mean perseus=; is your prompt? Strange.

Yes. perseus=; is the prompt.

 Actually sed is a line based command and should add a newline, imho.

I don't think it should add anything. For itself it should be able to count
newlines (because of the possible use of addresses), but otherwise it
should not do anything extra (it should be possible to pipe through
two seds, for instance).

Ruda



Re: [9fans] p9p sed vs linux sed

2015-08-12 Thread tlaronde
On Wed, Aug 12, 2015 at 09:57:18AM +0200, Rudolf Sykora wrote:
 On 12 August 2015 at 09:48, Ingo Krabbe ikrabbe@gmail.com wrote:
 
  Actually sed is a line based command and should add a newline, imho.
 
 I don't think it should add anything. For itself it should be able to count
 newlines (because of the possible use of addresses), but otherwise it
 should not do anything extra (it should be possible to pipe through
 two seds, for instance).
 

From the POSIX description (used here as some reference), when a
line is entered in the pattern space, the trailing new line is
discarded. When the pattern space is written to stdout it seems
that implicitely the new line is restored---the POSIX description
says that the input shall be a text file; and ISTR that with an
editor, a newline is entered to the last line because a text file
is considered to be an array of newline terminated lines.

This means that it is a grey zone and depends on things that are not all
explicitely stated and that the p9 sed(1) is not, from the/some
specification, at fault.
-- 
Thierry Laronde tlaronde +AT+ polynum +dot+ com
 http://www.kergis.com/
 http://www.arts-po.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C



Re: [9fans] read9pmsg usage

2015-08-12 Thread Giacomo Tesio
2015-08-12 9:25 GMT+02:00 David du Colombier 0in...@gmail.com:

 This comment is indeed pretty old. It was already present
 in the Second Edition.


So that check is based on pre 9p2000 code? If so, Charles have probably
explained it:

2015-08-10 17:40 GMT+02:00 Charles Forsyth charles.fors...@gmail.com:

 As a further historical note, originally 9P required a stream that
 preseved record boundaries, and the reliable datagram protocol IL/IP and
 pipes did that.


So, seem that ignoring zeros is simply wrong. A residual from the past...


Giacomo


Re: [9fans] p9p sed vs linux sed

2015-08-12 Thread Ingo Krabbe
Luckily plan9 is not POSIX and actually sed does not really add a newline 
character, it just puts a newline to the end of each pattern buffer, that is 
done line-wise anyway. Also sed's little brother ed behaves the same, which 
makes the behaviour even more convenient 

term% echo -n 'abc'  inp
term% cat inp
abcterm% ed inp
'\n' appended
4
wq
4
term%

And that is even consistent with (POSIX?) ed on linux systems or anywhere else.

There is a very good reason to do so: The rule just applies to the 
end-of-input! So when you output a pattern from the sed buffer, you would need 
to check each time if we are at the end or not and add the newline or not, if 
it has been there or not. All those branches for just one character at the end 
of the input that can be easily removed if you really don't want it.

So for simplicity there are very good reasons to state that any output from sed 
will end in a newline, even if the input doesn't.

If you seek for a sed like thing that does not work line oriented, use ssam, as 
sam and the streamed version ssam, process input in another way, that is not 
line oriented.

cheers
ingo

 On Wed, Aug 12, 2015 at 09:57:18AM +0200, Rudolf Sykora wrote:
 On 12 August 2015 at 09:48, Ingo Krabbe ikrabbe@gmail.com wrote:
 
  Actually sed is a line based command and should add a newline, imho.
 
 I don't think it should add anything. For itself it should be able to count
 newlines (because of the possible use of addresses), but otherwise it
 should not do anything extra (it should be possible to pipe through
 two seds, for instance).
 





Re: [9fans] p9p sed vs linux sed

2015-08-12 Thread lucio
 this, in my opinion, only complicates things.

You can't write a file in vi that does not end in a newline.  I never
found that problematic, even though sometimes one might wish to be
able to overrule vi.

So, I vote that text handling utilities should deal with all lines in
text files uniformly,even the last one.

Lucio.




Re: [9fans] Small Plan 9 Platforms

2015-08-12 Thread Brian L. Stuart
On Wed, 8/12/15, David du Colombier 0in...@gmail.com wrote:
  Is all that on sources somewhere or accessible otherwise?
 
 Richard's latest Raspberry Pi repository is available here:
 
 /n/sources/contrib/miller/9/bcm

Cool.  Somehow I missed that.  I'll pull it and play with it.  Using
the github plan9-bcm devbcm, I've gotten as far as blinking an
LED, but if there's already working I2C and SPI code, I've got
devices that need to talk that.

Thanks,
BLS




Re: [9fans] read9pmsg usage

2015-08-12 Thread Charles Forsyth
On 12 August 2015 at 10:18, Giacomo Tesio giac...@tesio.it wrote:

 So, seem that ignoring zeros is simply wrong. A residual from the past...


There doesn't seem to be any justification for it now, whatever the
original problem.
Even if there were something, I'd fix that instead of ignoring the
convention.