Loading...

help-make@gnu.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: Using environmnet variables in make Paul Smith Mon Mar 02 01:03:50 2009

On Sat, 2009-02-28 at 17:04 -0500, David Boyce wrote:
> On Sat, Feb 28, 2009 at 4:51 PM, Paul Smith <[EMAIL PROTECTED]> wrote:
>         In this example you actually don't even need to export
>         QA_STEP, since
>         only the shell is expanding it.  But, if you do really need to
>         export it
>         then please do it portably:
>         
>                test:
>                        @QA_STEP=start; export QA_STEP; <do-something>

> Since we're into pet peeves, and since as you note make uses /bin/sh,
> why not push
> 
> 
> test:
>         @QA_STEP=start <do-something>
> 
> as the recommended "elegant" option? It's worked on every /bin/sh ever
> made and it's the way one-shot exporting was originally designed to
> work.

In the original situation: export FOO=bar; touch $FOO
changing it to: FOO=bar touch $FOO
won't work since $FOO is expanded before FOO is assigned.

You're absolutely right, of course; in the case quoted above it's better
to do it your way, _but_ IFF <do-something> is a single command.  If
it's a longer script where QA_STEP is needed in multiple commands, you'd
need to export separately still.

Anyway, I wasn't trying to give a master class in shell programming best
practices, I just wanted to get rid of obvious non-portabilities :-)

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.us
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/help-make