git: a7c0df3a9c1c - main - shells/ksh-devel: Fix ksh 1.0.5 Regression (issue #660)

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Mon, 12 Jun 2023 09:20:15 UTC
The branch main has been updated by cy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a7c0df3a9c1c5235723f9db41e6c11ee4330123f

commit a7c0df3a9c1c5235723f9db41e6c11ee4330123f
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-06-12 09:13:16 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-06-12 09:19:56 +0000

    shells/ksh-devel: Fix ksh 1.0.5 Regression (issue #660)
    
    From issue #660:
    
    Globs are not expanded with the following:
    
    % echo "/"{bin,sbin}"/*"
    /bin/* /sbin/*
    
    % v=/; echo "$v"bin"/*"
    /bin/*
    
    But globbing is unexpectedly performed if both parameter substitution
    and brace expansion are present:
    
            % v=/; echo "$v"{bin,sbin}"/*"
            [output omitted for the sake of brevity]
    
    Obtained from:  https://github.com/ksh93/ksh/issues/660
---
 shells/ksh-devel/Makefile                             |  1 +
 shells/ksh-devel/files/patch-src_cmd_ksh93_sh_macro.c | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/shells/ksh-devel/Makefile b/shells/ksh-devel/Makefile
index 50dc9ae2290c..17c7428c9a9a 100644
--- a/shells/ksh-devel/Makefile
+++ b/shells/ksh-devel/Makefile
@@ -10,6 +10,7 @@
 
 PORTNAME=	ksh
 PORTVERSION=	${AST_COMMIT_DATE}
+PORTREVISION=	1
 CATEGORIES=	shells
 PKGNAMESUFFIX=	-devel
 
diff --git a/shells/ksh-devel/files/patch-src_cmd_ksh93_sh_macro.c b/shells/ksh-devel/files/patch-src_cmd_ksh93_sh_macro.c
new file mode 100644
index 000000000000..391cff245ac6
--- /dev/null
+++ b/shells/ksh-devel/files/patch-src_cmd_ksh93_sh_macro.c
@@ -0,0 +1,13 @@
+diff --git src/cmd/ksh93/sh/macro.c.orig src/cmd/ksh93/sh/macro.c
+index aba6f9d..0d60219 100644
+--- src/cmd/ksh93/sh/macro.c.orig
++++ src/cmd/ksh93/sh/macro.c
+@@ -2582,7 +2582,7 @@ static void endfield(Mac_t *mp,int split)
+ 		mp->atmode = 0;
+ 		if(mp->patfound)
+ 		{
+-			int musttrim = mp->wasexpan && !mp->noextpat && strchr(argp->argval,'\\');
++			int musttrim = mp->wasexpan && !mp->quoted && !mp->noextpat && strchr(argp->argval,'\\');
+ 			sh.argaddr = 0;
+ #if SHOPT_BRACEPAT
+ 			/* in POSIX mode, disallow brace expansion for unquoted expansions */