9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Ethan Grammatikidis <eekee57@fastmail.fm>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] rc word splitting trouble
Date: Sat,  3 Apr 2010 15:21:33 +0100	[thread overview]
Message-ID: <341DF8C2-A223-49A7-AA6C-65B7FB4C1CF5@fastmail.fm> (raw)

I'm writing a little web server in rc. For the most part it's been
less trouble than setting up Apache to serve static files, but I've
run into an odd little problem where rc appears to be behaving
differently depending on whether it's run in a script or a terminal.
(Rc & 9term from p9p.)

I'm testing with url: http://analytical-reengineering.dre.am/one/two?three+four

The script separates out the /one/two?three+four into a variable &
then splits that twice, first to get the 'file' part, which it does
correctly, then the arguments, which it has trouble with. You can see
the result at the url above. "three four" appear on 1 line where they
should be two. If I paste the same lines of code into a terminal, the
lines are split correctly:

% fullloc = '/one/two?three+four'
% params = `{echo $fullloc | sed -e 's;.*\?;;' -e 's;\+; ;g'}
% for(param in $params) echo '	<li>'$"param
	<li>three
	<li>four

The 2nd and 3rd command lines are copied directly from the script, but
the script itself outputs the following:

	<li>three four

The sed expressions appear to be working correctly, to my eyes, so I
don't understand what's going on.

--
Simplicity does not precede complexity, but follows it. -- Alan Perlis




             reply	other threads:[~2010-04-03 14:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-03 14:21 Ethan Grammatikidis [this message]
2010-04-03 14:38 ` erik quanstrom
2010-04-03 17:24   ` Ethan Grammatikidis

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=341DF8C2-A223-49A7-AA6C-65B7FB4C1CF5@fastmail.fm \
    --to=eekee57@fastmail.fm \
    --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).