From 4d7f36eea512377761f16ab24054c9b321b8539f Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker 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 3b44d5569a66..f2287bea5605 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 cb69b1358311..e35944c268de 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 000000000000..ce03cf96d62e --- /dev/null +++ b/bin/sh/tests/builtins/case23.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +case [ in +[[:alpha:]]) echo bad +esac