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