From nobody Tue Apr 7 07:08:24 2026 Received: from sender-of-o57.zoho.eu (sender-of-o57.zoho.eu [136.143.169.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59BB7374E62 for ; Sun, 15 Mar 2026 17:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773594675; cv=pass; b=Y1kOLkGPBpyDiqKQdsrAZ0OXJNEsH9fdbLf3SHLzvHiIGuxip0F5j8RZonlCki4KPODaM5rgVmubTeWxOvPQ4mY8OgFBesNWg7nMqHUFtC0MYfjQYcnIjoPhEYFdF7vnspfV2LM6kMUYnfP3xbvRJwl8Ado1voMrbb29k4RV6F4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773594675; c=relaxed/simple; bh=XgWFRb8ONcA2GQ/HdeRNANjgs9ScGEr/4d+esA/Kb7c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oeN/SbroLzh/CdR2vTd1WfQhug7rtu2r8OitGg9N5JZ+Y00utDU45Cxzy71e4OWuQ+KUsjWIeFfB73Iu70a+EsfTvuXGFeQh+RlBBFoWuVCzWjYA/VuGs1ztZq4WWU6a11mhzxF7d+UBQtTQT7nyuJ8cvExXsDQJB+ts1EdWKM4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=UOtZgMH/; arc=pass smtp.client-ip=136.143.169.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="UOtZgMH/" ARC-Seal: i=1; a=rsa-sha256; t=1773594669; cv=none; d=zohomail.eu; s=zohoarc; b=ZCZwAf/yf5DOf2iMjPNfQ5DwgHsM5VF7PFbfiyMXwp1GIsKB3SbQc5D9MNzFbl2GlMu+kYiOm4GJwFWoqM/b3sPX/u6c5HgR2fSwL2RhlzJXbAFBk6YwFrRIwVjoGmq79Ihl/RIlu6RMiE7ZmgMzPiMxePyTzTuLMahoupanXV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1773594669; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=6MFsWg559qWHVDZpDzdEbMHixOdjZsqRsUni07ha0iI=; b=S+IRbAvB4+mBYmZal8o/Q4KPYDioEMW8vRuMy12nimtKifgnFPza+t3skAF9X+W3OsMepfyf7asdP5EsFYCWmdFLDK3dC17QO8mDENwMgxBJnY/aSw5SWbgw8vyrSXn4vMCzWErOW48hI4tPKku454tQER3diyRjIUsgRydej+4= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773594669; s=zmail; d=objecting.org; i=objecting@objecting.org; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=6MFsWg559qWHVDZpDzdEbMHixOdjZsqRsUni07ha0iI=; b=UOtZgMH/r5BWkWSE8+Hxjgi69SDVYAhsAzj6wb+Ehe/bYEFSpOFE9Zqqoi9tHuqj 7gz/O6rXcs531KhREYQI6zyob+IC4UK2A24o788NHCC6KI+mWkpK1/rp6C+R16/8zw6 CzkxzBbc0seuFgLkBYEhOyybnJYwJEgBm1q0j8hI= Received: by mx.zoho.eu with SMTPS id 1773594667929445.6718407235394; Sun, 15 Mar 2026 18:11:07 +0100 (CET) From: Josh Law To: Andrew Morton , Josh Law Cc: linux-kernel@vger.kernel.org Subject: [PATCH 3/7] lib/glob: accept [^...] as character class negation syntax Date: Sun, 15 Mar 2026 17:11:00 +0000 Message-Id: <20260315171104.268944-4-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260315171104.268944-1-objecting@objecting.org> References: <20260315171104.268944-1-objecting@objecting.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" glob(7) specifies [!...] for negated character classes, but many users are more familiar with the regex-style [^...] syntax. Tools like git, rsync, and bash all accept both forms, and the difference is a common source of confusion when writing glob patterns. Accept '^' as an alias for '!' at the start of a character class so that both [!a-z] and [^a-z] work as expected. Signed-off-by: Josh Law --- lib/glob.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/glob.c b/lib/glob.c index df7f00619b1b..c5508be0d215 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -33,9 +33,9 @@ MODULE_LICENSE("Dual MIT/GPL"); * Like !fnmatch(@pat, @str, 0) and unlike the shell, this does NOT * treat / or leading . specially; it isn't actually used for pathnames. * - * Note that according to glob(7) (and unlike bash), character classes - * are complemented by a leading !; this does not support the regex-style - * [^a-z] syntax. + * Note that according to glob(7), character classes are complemented by + * a leading !. The regex-style [^a-z] syntax is also accepted as an + * alias. * * An opening bracket without a matching close is matched literally. */ @@ -72,7 +72,7 @@ bool __pure glob_match(char const *pat, char const *str) case '[': { /* Character class */ if (c =3D=3D '\0') /* No possible match */ return false; - bool match =3D false, inverted =3D (*pat =3D=3D '!'); + bool match =3D false, inverted =3D (*pat =3D=3D '!' || *pat =3D=3D '^'); char const *class =3D inverted ? pat + 1 : pat; unsigned char a =3D *class++; =20 --=20 2.34.1