On Oct 6, 2009, at 10:58 PM, Dan Drake wrote:
> On Tue, 06 Oct 2009 at 03:23AM -0700, Robert Bradshaw wrote: >> Is there not a way to invoke a bash script in such a way that it >> can't change the invoking environment? > > You sound like you want the `env' command: > > env FOO=bar command args > > runs "command args" with the variable $FOO set to "bar". When it > completes, $FOO is reset to what it was. The command can be basically > anything (although shell builtins don't quite seem to work as > expected). > If I may, let me try to clarify this issue, even though I understand it is tangential to the optimization thing, and what William and Dan said is right in practice. No process can affect the environment of its caller without special action. So while what you said is true, i.e., using ``env FOO=bar command'' wil invoke command without affecting the caller, so would ``command'', or ``FOO=bar command'' in sh-like shells. To nitpick, FOO is _not_ reset to what it was---it_never changed_ in the calling process. You have to go through special maneuvers (i.e. communication + interpretation) to do this upstream-environment change. The ``trick'' when you want to do that with shell scripts is, as William mentioned, to "source" the called script instead of invoking a separate shell. Another way is through standard communication, as ssh-agent does, for instance, using eval `ssh-agent ...`. Oh, and as env is a separate program that does exec*(), it cannot invoke builtins directly. Try env FOO=bar sh -c 'builtin'. And as I'm writing this, with regards to optimization flags, maybe the sage build system should provide an abstraction over -On. As I'm sure you know, these have widely differing behaviors across compilers. Sometimes -O3 will do nothing, sometimes it will break your code. ``high'', ``medium'' and ``low'' can be translated by an expert on the particular platform (os/compiler/compiler-version). Then again I'm thinking in general terms and maybe in the case of sage people don't build it or change flags so often and you can ignore this) --Vincent --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---