Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Originating-IP: [195.224.233.3] From: "John Vincent" To: cygwin AT cygwin DOT com, Andrew AT defaria DOT com Subject: Re: About ENV? Date: Thu, 24 Oct 2002 17:05:36 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 24 Oct 2002 17:05:36.0734 (UTC) FILETIME=[926AEFE0:01C27B7F] Hi, I think you are confusing shell variables with environment variables. This is easy to do if you are not careful, since shell variables can be put into the environment using the "export" built-in command. Still, they are different things, and in this case the assignment is to an environment variable, not to a shell variable. It's done to keep backwards-compatibility with old shell scripts. The command: AAA=aaa echo $AAA does NOT change the shell variable AAA it changes the environment variable AAA for the echo command only. Maybe this example will make it clearer: Administrator AT JPV ~ $ AAA=bbb Administrator AT JPV ~ $ AAA=aaa echo $AAA bbb Administrator AT JPV ~ $ In the above example the echo command is run with an environment variable AAA with a value of "aaa" but the shell variable AAA is passed with a value of "bbb" set on the previous line. I hope this helps. /John Vincent. >From: Igor Pechtchanski >Reply-To: cygwin AT cygwin DOT com >To: Andrew DeFaria >CC: cygwin AT cygwin DOT com >Subject: Re: About ENV? >Date: Fri, 18 Oct 2002 11:36:49 -0400 (EDT) > >On Fri, 18 Oct 2002, Andrew DeFaria wrote: > > > John Vincent wrote: > > > > > Hi, > > > > > > Not quite right there ... You can preceed a command with an > > > assignment, and the assigned variable is then put into the environment > > > of the command that is run. Thus the command > > > "echo" is run with an environment variable AAAA with the value aaaa. > > > However, this does not change the AAAA shell variable (which is > > > currently empty) so the echo prints a blank (it's empty argument) and > > > ignores the AAAA in it's environment. > > > > > > This syntax is useful for setting environment variables for one > > > command invocation only. They are not saved. > > > > > > I hope this fully explains what is going on. > > > > It doesn't. If "This syntax is useful for setting environment variables > > for one command invocation only" then the echo command should have > > echoed "aaa". Otherwise the syntax is not useful for setting environment > > variables for one command invocation. Perhaps what is meant is that this > > syntax is useful for overriding environment variables for one command > > invocation? However this leaves a glaring inconsistancy prone to error > > if the variable was not set already then no override takes place. > >Andrew, > >[pechtcha:~] AAAA=aaa && echo $AAAA >aaa >[pechtcha:~] AAAA=aaa echo $AAAA > >[pechtcha:~] AAAA=aaa eval 'echo $AAAA' >aaa >[pechtcha:~] AAAA=aaa sh -c 'echo $AAAA' >aaa >[pechtcha:~] > >Does this help? > Igor >-- > http://cs.nyu.edu/~pechtcha/ > |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu >ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com > |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski > '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! > >"Water molecules expand as they grow warmer" (C) Popular Science, Oct'02, >p.51 > > >-- >Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple >Bug reporting: http://cygwin.com/bugs.html >Documentation: http://cygwin.com/docs.html >FAQ: http://cygwin.com/faq/ _________________________________________________________________ Get a speedy connection with MSN Broadband.  Join now! http://resourcecenter.msn.com/access/plans/freeactivation.asp -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/