[PATCH] doc: Document another pitfall of shell pattern matching
Bruno Haible via Patches for autoconf - the GNU build system <[email protected]> Tue, 06 May 2025 10:18:11 +0200
| Newsgroups | gmane.comp.sysutils.autoconf.patches |
|---|---|
| Organization | GNU |
| Message-ID | <1791244.pYTLVKaXyH@nimes> |
This is a multi-part message in MIME format. --nextPart4305381.ZDofJx8uAJ Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Use of braces in shell patterns (globbing) is so common that I am surprised to see that it is not portable. Made that mistake: https://gitweb.git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=d23acdb852c5d69633d5761f6feca5d2df516c86 Here's a proposed change to the "Portable Shell Programming" chapter, to mention it. --nextPart4305381.ZDofJx8uAJ Content-Disposition: attachment; filename="0001-doc-Document-another-pitfall-of-shell-pattern-matchi.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-doc-Document-another-pitfall-of-shell-pattern-matchi.patch" From ace49a2691d82a027acd76787ce3508ae1fa9b9c Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Tue, 6 May 2025 09:57:56 +0200 Subject: [PATCH] doc: Document another pitfall of shell pattern matching. * doc/autoconf.texi (Shell Pattern Matching): Mention non-portability of patterns with braces. --- doc/autoconf.texi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 7b156b82..129e8018 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -16280,6 +16280,17 @@ some shells but not others; hence portable scripts should never use Outside the C locale, patterns like @samp{[a-z]} are problematic since they may match characters that are not lower-case letters. +Patterns with braces are, although not specified by POSIX, supported +by most shells. Not so by AIX 7.3 @command{/bin/sh}, though: + +@example +$ @kbd{ls -1 sequence000.c sequence999.c} +sequence000.c +sequence999.c +$ @kbd{ls -1 sequence@{000,999@}.c} +ls: 0653-341 The file sequence@{000,999@}.c does not exist. +@end example + @node Shell Substitutions @section Shell Substitutions @cindex Shell substitutions -- 2.43.0 --nextPart4305381.ZDofJx8uAJ--