9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: steve.simon@snellwilcox.com
To: 9fans@cse.psu.edu
Subject: [9fans] rc funny / my lack of understanding
Date: Fri,  3 Jan 2003 14:23:05 +0000	[thread overview]
Message-ID: <3276469819@snellwilcox.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]



Hi,

Attached is a bit of hget + rc + sam -d to get recent AP newswire
stories.

It has two modes - without an arg it lists the stories, with one it
prints that story.

The if statement seems to confuse the here document syntax of rc and it
start interpreting the tmp file as commands - all very odd.

If I remove the if statement and implement the program as two scripts
envoked seperately it works so the basic code must be right... I think.

I tried running the sam -d here document in a subshell ( @{...} )
but it still did the same thing.

Confused of Winchester,

-Steve



 

[-- Attachment #2: Newswire --]
[-- Type: application/octet-stream, Size: 675 bytes --]

#!/bin/rc
#
#	get AP news headline list or the given story
#

tmp=/tmp/tmp.$pid
wire='http://www.newsday.com/news/nationworld/wire'

if ( ~ $#* 0 ){
	hget $wire | grep headlines > $tmp
	sam -d $tmp >[2] /dev/null << 'EOF'
		,x/^.*sns-/d
		,x/,0,[0-9]*\.story.*">/c/@/
		,x/<\/a>/d
		w
	EOF
	awk -F@ '{printf("%-45s %s\n", $1, $2);}' $tmp
	rm -f $tmp
	exit 0
}

hget $wire/^sns-^$1^.story > $tmp
sam -d $tmp >[2] /dev/null << 'EOF'
	0,/END RELATED CONTENT RAIL/ d
	/^<\/font>$/,$ d
	,x/&copy;/ c/(c)/
	,x/&nbsp;/ c/ /
	,x/&lt;/ c/</
	,x/&gt;/ c/>/
	,x/&amp;/ c/&/
	,x/&nbsp;/ c/ /
	,x/&[a-z0-9][a-z0-9]*;/ d
	,x/<br>/ c/\n/
	,x/<[^>]*>/ d
	/^ *$/ d
	w
EOF
fmt $tmp
rm -f $tmp

             reply	other threads:[~2003-01-03 14:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-03 14:23 steve.simon [this message]
2003-01-03 16:00 ` Russ Cox

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=3276469819@snellwilcox.com \
    --to=steve.simon@snellwilcox.com \
    --cc=9fans@cse.psu.edu \
    /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).