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 '
'$"param
>> three
>> four
>>
>> The 2nd and 3rd command lines are copied directly from the script,
>> but
>> the script itself outputs the following:
>>
>> 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.