manpagez: man pages & more
info autoconf
Home | html | info | man

File: autoconf.info,  Node: Shell Pattern Matching,  Next: Shell Substitutions,  Prev: File System Conventions,  Up: Portable Shell

11.8 Shell Pattern Matching
===========================

Portable patterns should avoid the following constructs:

   • A bracket expression like ‘[a-z]’ outside the C locale.  This
     pattern may match characters that are not lower-case letters.
     Outside the C locale, use ‘[[:lower:]]’ instead, or to match just
     lower-case ASCII letters use ‘[abcdefghijklmnopqrstuvwxyz]’.

   • A bracket expression starting with ‘^’.  For example, ‘[!-aeiou]’
     is portable, but ‘[^-aeiou]’ is not.

   • When matching file names, a pattern containing ‘*’, ‘?’ or ‘[...]’
     that might match the file names ‘.’ or ‘..’.  For example ‘.*’
     might match ‘.’ and ‘..’, but it might not.

   • Any of the following characters, unless quoted or escaped or in a
     bracket expression:

          ! # % = [ ] ^ { } ~

     An unescaped ‘[’ that does not introduce a bracket expression is
     problematic because, for example, ‘a*[’ might match the file name
     ‘abc[’, but it might not.

     Curly braces are problematic because POSIX allows but does not
     require brace expansion.  For example, the shell command ‘echo
     a{b,c,d}e’ outputs ‘abe ace ade’ with Bash, but ‘a{b,c,d}e’ with
     Dash.

   • Backlashes in bracket expressions, unless doubled.  For example,
     ‘[\\^]’ is portable, but ‘[\^]’ is not.

   • An unescaped backslash at pattern end.

   • A NUL byte.  More generally, a NUL byte should never appear
     anywhere in a portable shell script.

© manpagez.com 2000-2026
Individual documents may contain additional copyright information.