This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Base-Files (was Re: Unset TMP/TEMP in profile?)

Christopher Faylor wrote:
On Wed, Dec 02, 2009 at 07:21:40PM +0100, Corinna Vinschen wrote:
On Dec 2 18:21, Thomas Wolff wrote:
Corinna Vinschen wrote in another thread about setting LANG:
... Andy and Thomas, please work
out the best solution together. It should work in sh and csh. Then
post it as reply to so
John can put it into the base-files package.
Our worked-out proposal is as follows:


# if no locale variable is set, indicate terminal charset via LANG
test -z "${LC_ALL:-${LC_CTYPE:-$LANG}}" && export LANG=C.UTF-8


# if no locale variable is set, indicate terminal charset via LANG
( test $?LC_ALL = 0 || test -z "$LC_ALL" ) && ( test $?LC_CTYPE = 0 || test -z "$LC_CTYPE" ) && ( test $?LANG = 0 || test -z "$LANG" ) && setenv LANG C.UTF-8
Thanks to both of you.

I wasn't paying attention before, so I apologize for not commenting
sooner but couldn't all of the above be one test statement or at least
handled inside '{}' rather than '()'. Maybe bash optimizes that away
but, if it doesn't, then forking subshells will be rather expensive on
For bash and other sh-alike shells, test is a built-in, but not for tcsh - sorry I did not consider this.
So an if statement should be used. I don't see, however, how {} would help - if you mean to embed an invocation of test
in an if expression, that doesn't help because test would still be forked.
The expression if ( $?LC_ALL == 0 || "$LC_ALL" == "" ) on the other doesn't work if LC_ALL is undefined because
|| inside an expression is not a conditional or, at least not with respect to variable substitution.
So I propose to neglect the unlikely possibility of an empty variable setting here and just test whether any of them is defined:

if ( $?LC_ALL == 0 && $?LC_CTYPE == 0 && $?LANG == 0 ) setenv LANG C.UTF-8


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]