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.

>From ace49a2691d82a027acd76787ce3508ae1fa9b9c Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
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

  • [PATCH] doc: ... Bruno Haible via Patches for autoconf - the GNU build system
    • Re: [PAT... Paul Eggert
      • Re: ... Bruno Haible via Patches for autoconf - the GNU build system

Reply via email to