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

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

 



Hi Paul,

On 3/26/07, Paul Eggert <eggert@xxxxxxxxxxx> wrote:
+@node Shell Pattern Matching
+@section Shell Pattern Matching
+@cindex Shell pattern matching
+
+Nowadays portable patterns can use negated character classes like
+@samp{[!-aeiou]}.  The older syntax @samp{[^-aeiou]} is supported by
+some shells but not others; hence portable scripts should never use
+@samp{^} 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


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux