autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why if test "xSTRING1= "xSTRING2" (the 'x') ?


From: Bruce Korb
Subject: Re: Why if test "xSTRING1= "xSTRING2" (the 'x') ?
Date: Mon, 26 Mar 2007 13:49:58 -0700

Hi Paul,

On 3/26/07, Paul Eggert <address@hidden> wrote:
address@hidden Shell Pattern Matching
address@hidden Shell Pattern Matching
address@hidden Shell pattern matching
+
+Nowadays portable patterns can use negated character classes like
address@hidden  The older syntax @samp{[^-aeiou]} is supported by
+some shells but not others; hence portable scripts should never use
address@hidden as the first character of a bracket pattern.
+
+Outside the C locale, patterns like @samp{[a-z]} are problematic since
+they may match characters that are not lower-case letters.

The default locale is the C locale.  Nevertheless, one shell (not ksh
or Solaris' sh)
thinks it is okay for [a-z] to match 'B' even when all locale
variables are undefined.
In other words, this:

 unset LANG `env|sed -n 's/=.*//;/^LC_/p'`
 ls [a-z]*

is insufficient.  Thus:

+Outside the C locale, and even sometimes in the defaulted-to C locale,
+patterns like @samp{[a-z]} are problematic since
+they may match characters that are not lower-case letters.

+but the @code{(} in this example is not portable to many older Bourne
+shell implementations.  It can be omitted safely.

Do we refer to the currently shipping Solaris 10 /bin/sh as an "older Bourne
shell implementation"?  A few might find it non-obvious that an "older
implementation" is still actively shipped.  :)

Cheers - Bruce




reply via email to

[Prev in Thread] Current Thread [Next in Thread]