and the vars don't seem to show up in the process list, though I'm no expert there lanx@lanx-1005HA:~$ ps -edaf |grep perl

ps' command line handling is quite messy: "e" and "-e" are completely different things. "-e" shows all processes, "e" shows the environment variables.

Environment variables are always visible, temporary or not.

So:

>env - foo=bar environment=unsafe sleep 100 & [1] 28318 >ps e | grep sl[e]ep 28318 pts/0 S 0:00 sleep 100 foo=bar environment=unsafe >

Or:

>foo=bar environment=unsafe sleep 100 & [1] 28338 >ps e | grep sl[e]ep 28338 pts/0 S 0:00 sleep 100 foo=bar environment=unsafe TERM=x +term SHELL=/bin/bash (... and many more) >

Update: So, effectively, there are no "temporary" environment variables, at least not when looking at process environments. Shells like bash have their own set of variables, they are often referenced to as environment variables, but they aren't, at least not all of them. "Exporting" variables, e.g. with export FOO, promotes a variable from a private piece of memory to an environment variable that is passed to other processes. Prefixing a command with variable=value does the same, inside the sub-process forked to execute the command.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^2: Set env variables as part of a command by afoken
in thread Set env variables as part of a command by devilock76

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.