9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] rc word splitting trouble
@ 2010-04-03 14:21 Ethan Grammatikidis
  2010-04-03 14:38 ` erik quanstrom
  0 siblings, 1 reply; 3+ messages in thread
From: Ethan Grammatikidis @ 2010-04-03 14:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-03 17:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-03 14:21 [9fans] rc word splitting trouble Ethan Grammatikidis
2010-04-03 14:38 ` erik quanstrom
2010-04-03 17:24   ` Ethan Grammatikidis

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).