public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Unusual environemtal variables
@ 2008-12-19  9:23 Steve Rainbird
  2008-12-19 13:46 ` Eric Blake
  0 siblings, 1 reply; 5+ messages in thread
From: Steve Rainbird @ 2008-12-19  9:23 UTC (permalink / raw)
  To: cygwin

When i run a Fuijitsu Cobol program it requires environmental variables 
starting with the @ sign.

SET @CBR_CONSOLE=SYSTEM

When I try and set these in a bash shell I get the following.

$ export @CBR_CONSOLE=SYSTEM
-bash: export: `@CBR_CONSOLE=SYSTEM': not a valid identifier

Is there any way around this?
-- 
Steve 



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

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

* Re: Unusual environemtal variables
  2008-12-19  9:23 Unusual environemtal variables Steve Rainbird
@ 2008-12-19 13:46 ` Eric Blake
  2008-12-21 16:07   ` Ehud Karni
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Blake @ 2008-12-19 13:46 UTC (permalink / raw)
  To: cygwin, steve.rainbird

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Steve Rainbird on 12/19/2008 2:22 AM:
> When i run a Fuijitsu Cobol program it requires environmental variables
> starting with the @ sign.

That is inherently non-portable.  POSIX states that "Other characters may
be permitted by an implementation; applications shall tolerate the
presence of such names," but does not require applications to be able to
create such names.

http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08

> 
> Is there any way around this?

You'll have to set it in Windows, prior to starting bash, as there is no
way to make bash create variables not starting with something from the
portable set [_a-zA-Z].

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net
volunteer cygwin bash maintainer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklLpWoACgkQ84KuGfSFAYAJqACfcK9X1ipv5NsVY7V6SWDpxO66
Lw0AnRW+z0+iQwaGNJZ2DgSYXjphSsUj
=3wby
-----END PGP SIGNATURE-----

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

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

* Re: Unusual environemtal variables
  2008-12-19 13:46 ` Eric Blake
@ 2008-12-21 16:07   ` Ehud Karni
  2008-12-21 19:44     ` Steve Rainbird
  2008-12-22 15:20     ` Mark J. Reed
  0 siblings, 2 replies; 5+ messages in thread
From: Ehud Karni @ 2008-12-21 16:07 UTC (permalink / raw)
  To: ebb9; +Cc: cygwin, steve.rainbird

On Fri, 19 Dec 2008 06:45:14 -0700, Eric Blake <ebb9@byu.net> wrote:
>
> According to Steve Rainbird on 12/19/2008 2:22 AM:
> SR:> When i run a Fuijitsu Cobol program it requires environmental variables
> SR:> starting with the @ sign.
>
> That is inherently non-portable.  POSIX states that "Other characters may
> be permitted by an implementation; applications shall tolerate the
> presence of such names," but does not require applications to be able to
> create such names.
>
> http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08
>
> SR:>
> SR:> Is there any way around this?
>
> You'll have to set it in Windows, prior to starting bash, as there is no
> way to make bash create variables not starting with something from the
> portable set [_a-zA-Z].

This behavior (accepting names of only ASCII Alpha and _) is a bash self
imposed limitation. If you use csh (or tcsh) names with other characters
are supported too.

So you can use csh's: setenv "@FOO" "value".
You can also use the env command to bypass bash limitation like this:
    exec env "@FOO=bar" exec /bin/bash -i
Note the 2 `exec' if you do not want to spawn more processes.

Ehud.


--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry

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

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

* Re: Unusual environemtal variables
  2008-12-21 16:07   ` Ehud Karni
@ 2008-12-21 19:44     ` Steve Rainbird
  2008-12-22 15:20     ` Mark J. Reed
  1 sibling, 0 replies; 5+ messages in thread
From: Steve Rainbird @ 2008-12-21 19:44 UTC (permalink / raw)
  To: cygwin



"Ehud Karni" <ehud@unix.mvs.co.il> wrote in message 
news:200812211606.mBLG6LX2014401@beta.mvs.co.il...
> On Fri, 19 Dec 2008 06:45:14 -0700, Eric Blake <ebb9@byu.net> wrote:
>>
>> According to Steve Rainbird on 12/19/2008 2:22 AM:
>> SR:> When i run a Fuijitsu Cobol program it requires environmental 
>> variables
>> SR:> starting with the @ sign.
>>
>> That is inherently non-portable.  POSIX states that "Other characters may
>> be permitted by an implementation; applications shall tolerate the
>> presence of such names," but does not require applications to be able to
>> create such names.
>>
>> http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08
>>
>> SR:>
>> SR:> Is there any way around this?
>>
>> You'll have to set it in Windows, prior to starting bash, as there is no
>> way to make bash create variables not starting with something from the
>> portable set [_a-zA-Z].
>
> This behavior (accepting names of only ASCII Alpha and _) is a bash self
> imposed limitation. If you use csh (or tcsh) names with other characters
> are supported too.
>
> So you can use csh's: setenv "@FOO" "value".
> You can also use the env command to bypass bash limitation like this:
>    exec env "@FOO=bar" exec /bin/bash -i
> Note the 2 `exec' if you do not want to spawn more processes.
>
> Ehud.
>
>
> --
> Ehud Karni           Tel: +972-3-7966-561  /"\
> Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
> Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
> http://www.mvs.co.il  FAX:  1-815-5509341  / \
> GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry
>


Thanks Eric and Ehud.

-- 
Steve 



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

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

* Re: Unusual environemtal variables
  2008-12-21 16:07   ` Ehud Karni
  2008-12-21 19:44     ` Steve Rainbird
@ 2008-12-22 15:20     ` Mark J. Reed
  1 sibling, 0 replies; 5+ messages in thread
From: Mark J. Reed @ 2008-12-22 15:20 UTC (permalink / raw)
  To: cygwin

Eric Blake:
> That is inherently non-portable.  POSIX states that "Other characters may
> be permitted by an implementation; applications shall tolerate the
> presence of such names," but does not require applications to be able to
> create such names.

Right.

Ehud Karni:
> This behavior (accepting names of only ASCII Alpha and _) is a bash self
> imposed limitation. If you use csh (or tcsh) names with other characters
> are supported too.

Somewhat overstated.

None of the shells I know of will let you set a shell
variable/parameter whose name doesn't match the standard ASCII
identifier pattern (initial letter or underscore followed by letters,
underscore, or digits):

bash$ @foo=bar
bash: @foo=bar: command not found

bash$ export @foo=bar
bash: export: `@foo=bar': not a valid identifier

tcsh% set @foo=bar
set: Variable name must begin with a letter.

Since in sh/bash/ksh, the only way to set an environment variable is
to first set a shell variable and then "export" it into the
environment, the above restriction on shell variables becomes a
restriction on environment variables, too.  Whereas in *csh, shell
variables and environment variables are set via different commands, so
the restriction on shell variables doesn't extend to the environment:

tcsh% setenv @FOO bar
tcsh%

Even in the *csh shells, however, environment variables are still
expanded via the same mechanism as shell variables, so the value of
one with a non-portable name is not accessible directly:

tcsh% echo $@FOO
Illegal variable name.

tcsh% echo ${@FOO}
Illegal variable name.

You have to use indirection, e.g.:

tcsh% setenv | awk -F= '($1=="@FOO") {print $2}'
bar

At least ash and bash leave variables with non-portable names in the
environment to pass on to child processes; it looks like zsh and ksh
(both AT&T and PD versions) strip them from the environment entirely:

env @FOO=bar ksh
ksh$ env | grep @FOO
ksh$

None of the foregoing is unique to Cygwin, however.  The intersection
is that there seem to be Windows applications which expect to inherit
environment variables with non-POSIX names, and Cygwin users such as
Steve who wish to launch such programs from the Cygwin environment.
The logical solution there is to do as Eric suggested and use env,
although if it's a simple script (or one you consider worth the
porting effort) you could also rewrite it in csh instead.

--
Mark J. Reed <markjreed@gmail.com>

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

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

end of thread, other threads:[~2008-12-22 15:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-19  9:23 Unusual environemtal variables Steve Rainbird
2008-12-19 13:46 ` Eric Blake
2008-12-21 16:07   ` Ehud Karni
2008-12-21 19:44     ` Steve Rainbird
2008-12-22 15:20     ` Mark J. Reed

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).