bash - Setting an environment variable on same line as program execution is different than setting it separately? - shell variables vs. environment variables -
what difference between:
prompt$ tsan_options="suppressions=/somewhere/file" ./myprogram
and
prompt$ tsan_options="suppressions=/somewhere/file" prompt$ ./myprogram
the thread-sanitizer library gives first case how library (used within myprogram) read file given in options. read it, , assumed supposed 2 separate lines, ran second case.
the library doesn't use file in second case, environment variable , program execution on separate lines.
what's difference?
bonus question: how first case run without error? shouldn't there have ; or && between them? answer question answers first...
the format var=value command
sets variable var
have value value
in environment of command command
. spec section covering simple commands. specifically:
otherwise, variable assignments shall exported execution environment of command , shall not affect current execution environment except side-effect of expansions performed in step 4.
the format var=value; command
sets shell variable var
in current shell , runs command
child process. child process doesn't know variables set in shell process.
the mechanism process exports (hint hint) variable seen child processes setting them in environment before running child process. shell built-in export
. why see export var=value
, var=value; export var
.
the syntax discussing short-form akin to:
var=value export var command unset -v var
only without using current process environment @ all.
Comments
Post a Comment