From 78d6d49b25f4bd11d01ae66f37f2b2c244931e17 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 29 Apr 2018 17:46:08 +0000 Subject: [PATCH] sh: Don't have [ match any [[:class:]] Submitted by: Robert Elz MFC after: 3 days --- bin/sh/expand.c | 4 +++- bin/sh/tests/builtins/Makefile | 1 + bin/sh/tests/builtins/case23.0 | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 bin/sh/tests/builtins/case23.0 diff --git a/bin/sh/expand.c b/bin/sh/expand.c index 3b44d5569a6..f2287bea560 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -1342,8 +1342,10 @@ patmatch(const char *pattern, const char *string) } if (c == '[' && *p == ':') { found |= match_charclass(p, chr, &end); - if (end != NULL) + if (end != NULL) { p = end; + continue; + } } if (c == CTLESC) c = *p++; diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile index cb69b135831..e35944c268d 100644 --- a/bin/sh/tests/builtins/Makefile +++ b/bin/sh/tests/builtins/Makefile @@ -42,6 +42,7 @@ ${PACKAGE}FILES+= case19.0 ${PACKAGE}FILES+= case20.0 ${PACKAGE}FILES+= case21.0 ${PACKAGE}FILES+= case22.0 +${PACKAGE}FILES+= case23.0 ${PACKAGE}FILES+= cd1.0 ${PACKAGE}FILES+= cd2.0 ${PACKAGE}FILES+= cd3.0 diff --git a/bin/sh/tests/builtins/case23.0 b/bin/sh/tests/builtins/case23.0 new file mode 100644 index 00000000000..ce03cf96d62 --- /dev/null +++ b/bin/sh/tests/builtins/case23.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +case [ in +[[:alpha:]]) echo bad +esac -- 2.45.0