On 3 Apr 2010, at 15:38, erik quanstrom wrote:
% fullloc = '/one/two?three+four' % params = `{echo $fullloc | sed -e 's;.*\?;;' -e 's;\+; ;g'} % for(param in $params) echo ' <li>'$"param <li>three <li>fourThe 2nd and 3rd command lines are copied directly from the script, butthe 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.i suspect your ifs is set to something funky. inserting a "whatis params" in your script would be pretty interesting. note that gnu sed will eat your regular expression since you \? is their meta character.
sed is p9p sed, verified with which, but ty.You're right about ifs, "whatis ifs" showed it up. It is set to newline-only for one line within the read loop, using the "var=foo command" syntax, but "command" in this case is another assignment. When I add a no-op command to the end (making it "assignment assignment command") rc complains "params: not found" and fails to run the loop properly. I don't know what kind of state the parser got into to produce that error.
Anyway, I've fixed it for now by re-setting ifs after the line in question.
I'm attaching the script; an embedded carriage-return makes a mess of both pasting the line here and posting it in a pastebin. The problem line is the first one in the while block.
web-script.rc
Description: Binary data
you can accomplish something that's equivalent in rc without an explicit loop: echo '<li>' ^ $params
Good to know. I haven't used it here because the for loop generates nicer html from nicer source, if that makes sense.
- erik
-- Simplicity does not precede complexity, but follows it. -- Alan Perlis