public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* incompatible environment variable names
@ 2010-08-04 16:24 Nellis, Kenneth
  2010-08-04 16:37 ` Steven Collins
  2010-08-06 18:46 ` Daniel Colascione
  0 siblings, 2 replies; 8+ messages in thread
From: Nellis, Kenneth @ 2010-08-04 16:24 UTC (permalink / raw)
  To: cygwin

I came across an interesting (IMHO) incompatibility between 
Windows and bash environment variable names.

I have a Windows environment variable as such:

C:\>set QNX_VISUAL_C++_PATH
QNX_VISUAL_C++_PATH=C:\Program Files\Orbital Qnx VisualC++ IDE

So, Windows has no problem with + symbols in variable names, but
bash does, kinda sorta:

Cygwin> printenv QNX_VISUAL_C++_PATH
C:\Program Files\Orbital Qnx VisualC++ IDE
Cygwin> cygpath "$QNX_VISUAL_C++_PATH"
++_PATH
Cygwin> echo "$QNX_VISUAL_C++_PATH"
++_PATH
Cygwin> echo ${QNX_VISUAL_C++_PATH}

Cygwin> cygpath "$(printenv QNX_VISUAL_C++_PATH)"
/cygdrive/c/Program Files/Orbital Qnx VisualC++ IDE
Cygwin>

So, it seems that I can only access the value of the variable 
through printenv, and then cygpath does what I need, but I can't 
then assign it back to the environment variable:

Cygwin> export QNX_VISUAL_C++_PATH="$(cygpath "$(printenv QNX_VISUAL_C++_PATH)")"
-bash: export: `QNX_VISUAL_C++_PATH=/cygdrive/c/Program Files/Orbital Qnx VisualC++ IDE': not a valid identifier
Cygwin>

I probably need to give up on this, but felt like sharing my misery.

--Ken Nellis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: incompatible environment variable names
  2010-08-04 16:24 incompatible environment variable names Nellis, Kenneth
@ 2010-08-04 16:37 ` Steven Collins
  2010-08-04 19:00   ` Nellis, Kenneth
  2010-08-06 18:46 ` Daniel Colascione
  1 sibling, 1 reply; 8+ messages in thread
From: Steven Collins @ 2010-08-04 16:37 UTC (permalink / raw)
  To: cygwin

On Wed, Aug 4, 2010 at 10:23, Nellis, Kenneth wrote:
> I came across an interesting (IMHO) incompatibility between
> Windows and bash environment variable names.
>
> I have a Windows environment variable as such:
>
> C:\>set QNX_VISUAL_C++_PATH
> QNX_VISUAL_C++_PATH=C:\Program Files\Orbital Qnx VisualC++ IDE
>
> So, Windows has no problem with + symbols in variable names, but
> bash does, kinda sorta:
>
> Cygwin> printenv QNX_VISUAL_C++_PATH
> C:\Program Files\Orbital Qnx VisualC++ IDE
> Cygwin> cygpath "$QNX_VISUAL_C++_PATH"
> ++_PATH
> Cygwin> echo "$QNX_VISUAL_C++_PATH"
> ++_PATH
> Cygwin> echo ${QNX_VISUAL_C++_PATH}
>
> Cygwin> cygpath "$(printenv QNX_VISUAL_C++_PATH)"
> /cygdrive/c/Program Files/Orbital Qnx VisualC++ IDE
> Cygwin>
>
> So, it seems that I can only access the value of the variable
> through printenv, and then cygpath does what I need, but I can't
> then assign it back to the environment variable:
>
> Cygwin> export QNX_VISUAL_C++_PATH="$(cygpath "$(printenv QNX_VISUAL_C++_PATH)")"
> -bash: export: `QNX_VISUAL_C++_PATH=/cygdrive/c/Program Files/Orbital Qnx VisualC++ IDE': not a valid identifier
> Cygwin>
>
> I probably need to give up on this, but felt like sharing my misery.
>
> --Ken Nellis
>

From the bash man page:

<bashManPage>
<snip/>

DEFINITIONS
       The following definitions are used throughout the rest of this document.
       blank  A space or tab.
       word   A sequence of characters considered as a single unit by
the shell.  Also known as a token.
       name   A word consisting only of alphanumeric characters and
underscores, and beginning with an alphabetic character or an
underscore.  Also referred to as an identifier.

<snip/>


PARAMETERS
       A parameter is an entity that stores values.  It can be a name,
a number, or one of the special characters listed below under Special
Parameters.  A variable is a parameter denoted by a name.  A variable
has a value and zero or more attributes.  Attributes are  assigned
using
       the declare builtin command (see declare below in SHELL BUILTIN
COMMANDS).

<snip/>
</bashManPage>

Hench bash does not support the plus character in a variable name and
no amount of finagling is going to fix it.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: incompatible environment variable names
  2010-08-04 16:37 ` Steven Collins
@ 2010-08-04 19:00   ` Nellis, Kenneth
  2010-08-04 19:06     ` Andy Koppe
                       ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Nellis, Kenneth @ 2010-08-04 19:00 UTC (permalink / raw)
  To: cygwin

> From: Steven Collins
> On Wed, Aug 4, 2010 at 10:23, Nellis, Kenneth wrote:
> > I came across an interesting (IMHO) incompatibility between
> > Windows and bash environment variable names.
> >
> > I have a Windows environment variable as such:
> >
> > C:\>set QNX_VISUAL_C++_PATH
> > QNX_VISUAL_C++_PATH=C:\Program Files\Orbital Qnx VisualC++ IDE
> >
> > So, Windows has no problem with + symbols in variable names, but
> > bash does, kinda sorta:
> >
> > Cygwin> printenv QNX_VISUAL_C++_PATH
> > C:\Program Files\Orbital Qnx VisualC++ IDE
> > Cygwin> cygpath "$QNX_VISUAL_C++_PATH"
> > ++_PATH
> > Cygwin> echo "$QNX_VISUAL_C++_PATH"
> > ++_PATH
> > Cygwin> echo ${QNX_VISUAL_C++_PATH}
> >
> > Cygwin> cygpath "$(printenv QNX_VISUAL_C++_PATH)"
> > /cygdrive/c/Program Files/Orbital Qnx VisualC++ IDE
> > Cygwin>
> >
> > So, it seems that I can only access the value of the variable
> > through printenv, and then cygpath does what I need, but I can't
> > then assign it back to the environment variable:
> >
> > Cygwin> export QNX_VISUAL_C++_PATH="$(cygpath "$(printenv
> QNX_VISUAL_C++_PATH)")"
> > -bash: export: `QNX_VISUAL_C++_PATH=/cygdrive/c/Program Files/Orbital
> Qnx VisualC++ IDE': not a valid identifier
> > Cygwin>
> >
> > I probably need to give up on this, but felt like sharing my misery.
> >
> > --Ken Nellis
> >
> 
> From the bash man page:
<snip/>
> 
> Hench bash does not support the plus character in a variable name and
> no amount of finagling is going to fix it.

Well, *somehow* it got into the Cygwin environment, and cygwin.bat directly
invokes bash, so I interpret this as bash creating the Cygwin environment.
Where is the hole in this logic?

--Ken Nellis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: incompatible environment variable names
  2010-08-04 19:00   ` Nellis, Kenneth
@ 2010-08-04 19:06     ` Andy Koppe
  2010-08-04 19:09     ` Eric Blake
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Andy Koppe @ 2010-08-04 19:06 UTC (permalink / raw)
  To: cygwin

On 4 August 2010 19:59, Nellis, Kenneth wrote:
>> > Cygwin> export QNX_VISUAL_C++_PATH="$(cygpath "$(printenv
>> QNX_VISUAL_C++_PATH)")"
>> > -bash: export: `QNX_VISUAL_C++_PATH=/cygdrive/c/Program Files/Orbital
>> Qnx VisualC++ IDE': not a valid identifier
>> > Cygwin>
>> >
>> > I probably need to give up on this, but felt like sharing my misery.
>>
>> bash does not support the plus character in a variable name and
>> no amount of finagling is going to fix it.
>
> Well, *somehow* it got into the Cygwin environment, and cygwin.bat directly
> invokes bash, so I interpret this as bash creating the Cygwin environment.
> Where is the hole in this logic?

The Windows environment is translated by the Cygwin DLL, which gets
loaded and initialised when bash.exe is invoked.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: incompatible environment variable names
  2010-08-04 19:00   ` Nellis, Kenneth
  2010-08-04 19:06     ` Andy Koppe
@ 2010-08-04 19:09     ` Eric Blake
  2010-08-04 19:24     ` Corinna Vinschen
  2010-08-04 19:25     ` Andrey Repin
  3 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2010-08-04 19:09 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]

On 08/04/2010 12:59 PM, Nellis, Kenneth wrote:
>> From: Steven Collins
>> On Wed, Aug 4, 2010 at 10:23, Nellis, Kenneth wrote:
>>> I came across an interesting (IMHO) incompatibility between
>>> Windows and bash environment variable names.

Not just windows, but any system with environment variables.

Anyone can call execve and set arbitrary strings in the environment that
do not correspond to valid environment variables in the shell.  Bash can
inherit such invalid names, at which point, POSIX says that bash may,
but not must, preserve those invalid names to pass on to children, even
though they cannot be accessed from within the shell itself.

> 
> Well, *somehow* it got into the Cygwin environment, and cygwin.bat directly
> invokes bash, so I interpret this as bash creating the Cygwin environment.
> Where is the hole in this logic?

Bash does not create the cygwin environment.  Rather, it inherits the
environment from the parent process.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: incompatible environment variable names
  2010-08-04 19:00   ` Nellis, Kenneth
  2010-08-04 19:06     ` Andy Koppe
  2010-08-04 19:09     ` Eric Blake
@ 2010-08-04 19:24     ` Corinna Vinschen
  2010-08-04 19:25     ` Andrey Repin
  3 siblings, 0 replies; 8+ messages in thread
From: Corinna Vinschen @ 2010-08-04 19:24 UTC (permalink / raw)
  To: cygwin

On Aug  4 13:59, Nellis, Kenneth wrote:
> > From: Steven Collins
> > On Wed, Aug 4, 2010 at 10:23, Nellis, Kenneth wrote:
> > > [...]
> > > So, Windows has no problem with + symbols in variable names, but
> > > bash does, kinda sorta:
> > > [...]
> > 
> > From the bash man page:
> <snip/>
> > 
> > Hench bash does not support the plus character in a variable name and
> > no amount of finagling is going to fix it.
> 
> Well, *somehow* it got into the Cygwin environment, and cygwin.bat directly
> invokes bash, so I interpret this as bash creating the Cygwin environment.
> Where is the hole in this logic?

The environment is converted by the Cygwin DLL, not by bash.  And, even
though the '+' character is *theoretically* allowed in a POSIX
environment variable name(*), neither bash nor tcsh(**) handles it
transparently as part of a variable name.  This is *not* a Cygwin
problem(**).

(*) http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
    Accentuation added by me:

  [...]
  Environment variable names used by the utilities in the Shell and
  Utilities volume of POSIX.1-2008 consist solely of uppercase letters,
  digits, and the <underscore> ( '_' ) from the characters defined in
  [ASCII] and do not begin with a digit. Other characters *may* be
  permitted by an implementation; applications *shall* tolerate the
  presence of such names.

(**) On Linux:

  tcsh$ $ echo $version
  tcsh 6.17.00 (Astron) 2009-07-10 (x86_64-unknown-linux) options wide,nls,dl,al,kan,rh,color,filec
  tcsh$ setenv QNX_VISUAL_C++_PATH foo
  tcsh$ env | grep QN
  QNX_VISUAL_C++_PATH=foo
  tcsh$ echo $QNX_VISUAL_C++_PATH
  QNX_VISUAL_C: Undefined variable.
  tcsh$ echo ${QNX_VISUAL_C++_PATH}
  Missing }.
  tcsh$ echo "$QNX_VISUAL_C++_PATH"
  QNX_VISUAL_C: Undefined variable.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: incompatible environment variable names
  2010-08-04 19:00   ` Nellis, Kenneth
                       ` (2 preceding siblings ...)
  2010-08-04 19:24     ` Corinna Vinschen
@ 2010-08-04 19:25     ` Andrey Repin
  3 siblings, 0 replies; 8+ messages in thread
From: Andrey Repin @ 2010-08-04 19:25 UTC (permalink / raw)
  To: Nellis, Kenneth, cygwin

Greetings, Nellis, Kenneth!

> Well, *somehow* it got into the Cygwin environment, and cygwin.bat directly
> invokes bash, so I interpret this as bash creating the Cygwin environment.
> Where is the hole in this logic?

Even windows itself creates environment variables inaccessible through CMD.
Still, they are available to running programs.
On another edge, TC(ex. 4NT) shell support variables that not actually
environmental, rather - status variables related to current shell state or
recently happened events.
There's no logic, just usefulness.


--
WBR,
 Andrey Repin (anrdaemon@freemail.ru) 04.08.2010, <23:18>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: incompatible environment variable names
  2010-08-04 16:24 incompatible environment variable names Nellis, Kenneth
  2010-08-04 16:37 ` Steven Collins
@ 2010-08-06 18:46 ` Daniel Colascione
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel Colascione @ 2010-08-06 18:46 UTC (permalink / raw)
  To: 'Nellis, Kenneth', cygwin

Nellis, Kenneth:
> I came across an interesting (IMHO) incompatibility between Windows and bash environment variable names.

You can create odd environment names on Unixish systems too, but nobody relies on them.

I've had the same issue; a build environment I use required the presence of variable names with '(' and ')' in them. For the moment, I've hacked around the issue by calling cmd.exe to do the work before launching the build system proper, but eventually, in my Copious Free Time(TM), my plan is to patch bash and add raw-getenv and raw-setenv builtins that do the obvious thing.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-08-06 18:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-04 16:24 incompatible environment variable names Nellis, Kenneth
2010-08-04 16:37 ` Steven Collins
2010-08-04 19:00   ` Nellis, Kenneth
2010-08-04 19:06     ` Andy Koppe
2010-08-04 19:09     ` Eric Blake
2010-08-04 19:24     ` Corinna Vinschen
2010-08-04 19:25     ` Andrey Repin
2010-08-06 18:46 ` Daniel Colascione

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).