9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Duff's rc paper: Why awk?
@ 2013-06-07 13:02 markus schnalke
  2013-06-07 13:18 ` erik quanstrom
  0 siblings, 1 reply; 4+ messages in thread
From: markus schnalke @ 2013-06-07 13:02 UTC (permalink / raw)
  To: 9fans

Hoi,

I've read [0], which is enlightening btw, but there is one thing,
in Section 27, which I don't understand: Why is awk(1) used there?

	fn read{
		$1=`{awk '{print;exit}'}
	}

[0] http://static.tobold.org/rc/rc-duff.html

I rather would have used sed(1), which is less distracting in this
case:

	fn read{
		$1=`{sed q}
	}

This use of awk is unexpected to me, it draws my attention on it,
thus I'm searching for the strange hidden detail that might be
emphasized. (Such as the use of `if not' instead of `else'.) But I
can't find it.

Maybe there is no such hidden detail. Maybe there is no real
reason behind the use of awk here. I'm not really sure ...


meillo



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

* Re: [9fans] Duff's rc paper: Why awk?
  2013-06-07 13:02 [9fans] Duff's rc paper: Why awk? markus schnalke
@ 2013-06-07 13:18 ` erik quanstrom
  2013-06-11 12:24   ` Rudolf Sykora
  0 siblings, 1 reply; 4+ messages in thread
From: erik quanstrom @ 2013-06-07 13:18 UTC (permalink / raw)
  To: 9fans

> I've read [0], which is enlightening btw, but there is one thing,
> in Section 27, which I don't understand: Why is awk(1) used there?
>
> 	fn read{
> 		$1=`{awk '{print;exit}'}
> 	}
>
> [0] http://static.tobold.org/rc/rc-duff.html
>
> I rather would have used sed(1), which is less distracting in this
> case:
>
> 	fn read{
> 		$1=`{sed q}
> 	}
>
> This use of awk is unexpected to me, it draws my attention on it,
> thus I'm searching for the strange hidden detail that might be
> emphasized. (Such as the use of `if not' instead of `else'.) But I
> can't find it.
>
> Maybe there is no such hidden detail. Maybe there is no real
> reason behind the use of awk here. I'm not really sure ...

plan 9 sed reads a second line before quitting (note the "def" in the example
below); sed does not work.

- erik
------
; fn read{
	$1=`{sed q}
	echo read `{whatis $1}
}
; read x
abc
def
read x=abc
; fn read{
	$1=`{awk '{print;exit}'}
	echo read `{whatis $1}
}
; read x
abc
read x=abc



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

* Re: [9fans] Duff's rc paper: Why awk?
  2013-06-07 13:18 ` erik quanstrom
@ 2013-06-11 12:24   ` Rudolf Sykora
  2013-06-11 15:38     ` markus schnalke
  0 siblings, 1 reply; 4+ messages in thread
From: Rudolf Sykora @ 2013-06-11 12:24 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> plan 9 sed reads a second line before quitting (note the "def" in the example
> below); sed does not work.

Is there any good reason for this difference between plan9 and gnu behaviour?

Thanks!
Ruda



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

* Re: [9fans] Duff's rc paper: Why awk?
  2013-06-11 12:24   ` Rudolf Sykora
@ 2013-06-11 15:38     ` markus schnalke
  0 siblings, 0 replies; 4+ messages in thread
From: markus schnalke @ 2013-06-11 15:38 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[2013-06-11 14:24] Rudolf Sykora <rudolf.sykora@gmail.com>
> > plan 9 sed reads a second line before quitting (note the "def" in the example
> > below); sed does not work.

Erik, thanks for the explanation.

However, the man page states:

	q       Quit. Branch to the end of the script. Do not start a new cycle.

Thus, this is a bit odd.


> Is there any good reason for this difference between plan9 and gnu behaviour?

It looks a bit like the bug described in the man page, although input is read
from the terminal, not from a pipe.

http://plan9.bell-labs.com/magic/man2html/1/sed


meillo



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

end of thread, other threads:[~2013-06-11 15:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-07 13:02 [9fans] Duff's rc paper: Why awk? markus schnalke
2013-06-07 13:18 ` erik quanstrom
2013-06-11 12:24   ` Rudolf Sykora
2013-06-11 15:38     ` markus schnalke

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