> 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

Reply via email to