X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,FB_WORD1_END_DOLLAR,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Message-ID: Date: Mon, 22 Dec 2008 10:19:56 -0500 From: "Mark J. Reed" To: cygwin AT cygwin DOT com Subject: Re: Unusual environemtal variables In-Reply-To: <200812211606.mBLG6LX2014401@beta.mvs.co.il> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <494BA56A DOT 7070009 AT byu DOT net> <200812211606 DOT mBLG6LX2014401 AT beta DOT mvs DOT co DOT il> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 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 -- 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/