From: "Russ Cox" <rsc@swtch.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@9fans.net>
Subject: Re: [9fans] sam/rc script problem
Date: Tue, 16 Dec 2008 09:18:00 -0800 [thread overview]
Message-ID: <dd6fe68a0812160918x66bef4e4s552dca80913ab36c@mail.gmail.com> (raw)
In-Reply-To: <a560a5d00812160425g2cc7b8a3u11eb7f1ea85c47b2@mail.gmail.com>
> why do I get, running rc in linux (plan9port)
> -----------------------------
> ; sam -d outit
> -. outit
> $-/FERMI/+-
> FERMI LEVEL= 0.01 ITER= 70
> q
> -----------------------------
> -----------------------------
> ; sam -d outit <<EOF
> $-/FERMI/+-
> q
> EOF
> -. outit
> FERMI LEVEL= 0.07 ITER= 1
> -----------------------------
>
> that is, the second way finds the 1st occurence in the file while I
> want the last one (as in the first case)?!
> In Plan9 it works the same in both cases!
It works the same in both cases on Plan 9 only accidentally.
It turns out that $-/FERMI/ is the same as -/FERMI/ -- if you are
searching backward it doesn't matter whether you start at $
or at the beginning of the file. On Plan 9:
cpu% cat <<EOF
$-/FERMI/+-
EOF
-/FERMI/+-
cpu%
Using the plan9port rc, I get the same behavior:
$ /usr/local/plan9/bin/rc # plan9port rc
c2=; cat <<EOF
$-/FERMI/+-
EOF
-/FERMI/+-
c2=;
However, it looks like you are using Byron's Unix rc
implementation, not the plan9port one:
$ /usr/bin/rc # byron's rc
c2=; cat <<EOF
$-/FERMI/+-
EOF
/FERMI/+-
c2=;
It leaves out the leading "-", which causes sam to do
a forward search and find a different line.
In all three cases, if you want to pass a $ through
uninterpreted, you should be using <<'EOF' not <<EOF.
Russ
next prev parent reply other threads:[~2008-12-16 17:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-16 12:25 Rudolf Sykora
2008-12-16 13:02 ` lucio
2008-12-16 13:08 ` Steve Simon
2008-12-16 14:00 ` erik quanstrom
2008-12-16 14:13 ` gdiaz
2008-12-16 16:22 ` Rudolf Sykora
2008-12-16 16:38 ` erik quanstrom
2008-12-16 16:56 ` Rudolf Sykora
2008-12-16 17:29 ` Martin Neubauer
2008-12-16 14:05 ` Charles Forsyth
2008-12-16 19:25 ` Rudolf Sykora
2008-12-16 19:29 ` erik quanstrom
2008-12-16 19:43 ` michael block
2008-12-16 20:14 ` Rudolf Sykora
2008-12-16 17:18 ` Russ Cox [this message]
2008-12-16 17:28 ` Rudolf Sykora
2008-12-16 17:31 ` erik quanstrom
2008-12-16 17:48 ` Rudolf Sykora
2008-12-16 18:13 ` erik quanstrom
2008-12-16 18:38 ` Charles Forsyth
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=dd6fe68a0812160918x66bef4e4s552dca80913ab36c@mail.gmail.com \
--to=rsc@swtch.com \
--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).