%% "Huiseok Kim" <[EMAIL PROTECTED]> writes: hk> <style> p {margin-top:0px;margin-bottom:0px;} </style><table border=0 width=100% bgcolor='' cellpadding=0 cellspacing=0 align=center><tr><td valign=top style='padding:8pt;'><font size=2><P>it looks strange that the variable in the shell doesn't work with builtin function. following is one of the situation:</P>
Please don't post HTML. hk> list = foo/bar google deep/deeper/deepest hk> test: hk> for item in $(list); do \ hk> echo $(notdir $$item); \ hk> done hk> result: hk> foo/bar hk> google hk> deep/deeper/deepest hk> i had expected to be listed it as 'bar google deepest' No. You must keep very firmly in mind the distinction between the shell and make. Make handles resolving all make variables and functions, THEN it takes the results of that and hands it to the shell, and the shell executes it. That's the ONLY interaction between them. So, make expands the script BEFORE it invokes the shell. Once the shell gets the results, there's nothing make can do with it; the shell is a separate process. Here you are trying to mix a shell construct (the for loop) and have a make function (notdir) be invoked each time through the loop; that can't work. Make expands the $(notdir $$item) before it runs the shell, so the shell gets this to run: for item in foo/bar google deep/deeper/deepest; do echo $item; done You need to invoke the make function on the _make_ variable, not the _shell_ variable; you can do this: test: for item in $(notdir $(list)); do \ echo $$item; \ done Or, if that doesn't do what you need, you'll have to use a _shell_ "function" on the shell variable, not a make function: test: for item in $(list); do \ echo `basename $$item`; \ done -- ------------------------------------------------------------------------------- Paul D. Smith <[EMAIL PROTECTED]> Find some GNU make tips at: http://www.gnu.org http://make.paulandlesley.org "Please remain calm...I may be mad, but I am a professional." --Mad Scientist _______________________________________________ Bug-make mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-make