9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] Duff's rc paper: Why awk?
Date: Fri,  7 Jun 2013 09:18:26 -0400	[thread overview]
Message-ID: <bdd43bfc464622878b43260e4c0f4134@kw.quanstro.net> (raw)
In-Reply-To: <1UkwIw-2xe-00@marmaro.de>

> 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



  reply	other threads:[~2013-06-07 13:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07 13:02 markus schnalke
2013-06-07 13:18 ` erik quanstrom [this message]
2013-06-11 12:24   ` Rudolf Sykora
2013-06-11 15:38     ` markus schnalke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bdd43bfc464622878b43260e4c0f4134@kw.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).