On Fri, 14 Jul 2006, Scott Smedley wrote:

Hi all,

Help please.

addtofunc fn
+ i echo executing $[0-]
+ i $[0-]
fn echo hello

How come fn doesn't print out "hello"?


After some time debuging it turns out to be problem with the parse function usage. I'm not sure the best way to fix it, but this is what happens:

in functions.c the functon to execute is peeked from the action string. It's then passed to expand_vars. Before expand_args_extended no parsefunctions were used in expand_vars, so everything was good. With expand_args_extended using PeekToken the input to expand_vars gets overwritten and the expansion fails.

expand_vars is only called from functions.c, once with a peeked token and once on the entire action string. Looking at the code I'm not even sure why it can't do things the other way around. (First expand and then peek the function name.) In fact the curent behaviour seems wrong as per this example:
AddToFunc TestFunc
+ I "Echo Hello" hello
+ I $*
TestFunc "Echo Hello" hello

This will print hello and produce an error. If expansion was made before the function token is peeked it will produce the exact same result.

/Viktor

Reply via email to