If a here-document starts before a $() command substitution and ends after it, 
ksh produces an error

here-document
not contained within command substitution

the attached patch fixes it, but it is a bit of a hack, I am not sure if it is 
the best possible solution.

Example that shows the problem

cat <<EOI > $TMPDIR/$(basename $0)3
foobar
baz
EOI

for some reason it doesn't happen with `, so

cat <<EOI>$TMPDIR/`basename $0`3
foobar
baz
EOI

works

Anders
Only in ksh93: arch
Only in ksh93/bin: execrate
Only in ksh93/bin: execrate.old
diff -upr ksh93.orig/bin/ignore ksh93/bin/ignore
--- ksh93.orig/bin/ignore	2012-03-05 17:26:32.000000000 +0100
+++ ksh93/bin/ignore	2013-02-22 13:09:26.538379474 +0100
@@ -1,3 +1,22 @@
+########################################################################
+#                                                                      #
+#               This software is part of the ast package               #
+#          Copyright (c) 1994-2011 AT&T Intellectual Property          #
+#                      and is licensed under the                       #
+#                 Eclipse Public License, Version 1.0                  #
+#                    by AT&T Intellectual Property                     #
+#                                                                      #
+#                A copy of the License is available at                 #
+#          http://www.eclipse.org/org/documents/epl-v10.html           #
+#         (with md5 checksum b35adb5213ca9657e911e9befb180842)         #
+#                                                                      #
+#              Information and Software Systems Research               #
+#                            AT&T Research                             #
+#                           Florham Park NJ                            #
+#                                                                      #
+#                 Glenn Fowler <[email protected]>                  #
+#                                                                      #
+########################################################################
 # non-ksh script for the nmake ignore prefix
 # @(#)ignore (AT&T Research) 1992-08-11
 
diff -upr ksh93.orig/bin/mamprobe ksh93/bin/mamprobe
--- ksh93.orig/bin/mamprobe	2012-03-05 17:26:32.000000000 +0100
+++ ksh93/bin/mamprobe	2013-02-22 13:09:26.538379474 +0100
@@ -1,3 +1,22 @@
+########################################################################
+#                                                                      #
+#               This software is part of the ast package               #
+#          Copyright (c) 1994-2011 AT&T Intellectual Property          #
+#                      and is licensed under the                       #
+#                 Eclipse Public License, Version 1.0                  #
+#                    by AT&T Intellectual Property                     #
+#                                                                      #
+#                A copy of the License is available at                 #
+#          http://www.eclipse.org/org/documents/epl-v10.html           #
+#         (with md5 checksum b35adb5213ca9657e911e9befb180842)         #
+#                                                                      #
+#              Information and Software Systems Research               #
+#                            AT&T Research                             #
+#                           Florham Park NJ                            #
+#                                                                      #
+#                 Glenn Fowler <[email protected]>                  #
+#                                                                      #
+########################################################################
 ### this script contains archaic constructs that work with all sh variants ###
 # mamprobe - generate MAM cc probe info
 # Glenn Fowler <[email protected]>
diff -upr ksh93.orig/bin/package ksh93/bin/package
--- ksh93.orig/bin/package	2012-03-08 22:07:19.000000000 +0100
+++ ksh93/bin/package	2013-02-22 13:09:26.539379475 +0100
@@ -1,4 +1,23 @@
 USAGE_LICENSE="[-author?Glenn Fowler <[email protected]>][-copyright?Copyright (c) 1994-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?INIT]";
+########################################################################
+#                                                                      #
+#               This software is part of the ast package               #
+#          Copyright (c) 1994-2012 AT&T Intellectual Property          #
+#                      and is licensed under the                       #
+#                 Eclipse Public License, Version 1.0                  #
+#                    by AT&T Intellectual Property                     #
+#                                                                      #
+#                A copy of the License is available at                 #
+#          http://www.eclipse.org/org/documents/epl-v10.html           #
+#         (with md5 checksum b35adb5213ca9657e911e9befb180842)         #
+#                                                                      #
+#              Information and Software Systems Research               #
+#                            AT&T Research                             #
+#                           Florham Park NJ                            #
+#                                                                      #
+#                 Glenn Fowler <[email protected]>                  #
+#                                                                      #
+########################################################################
 ### this script contains archaic constructs that work with all sh variants ###
 # package - source and binary package control
 # Glenn Fowler <[email protected]>
diff -upr ksh93.orig/bin/silent ksh93/bin/silent
--- ksh93.orig/bin/silent	2012-03-05 17:26:32.000000000 +0100
+++ ksh93/bin/silent	2013-02-22 13:09:26.540379476 +0100
@@ -1,3 +1,22 @@
+########################################################################
+#                                                                      #
+#               This software is part of the ast package               #
+#          Copyright (c) 1994-2011 AT&T Intellectual Property          #
+#                      and is licensed under the                       #
+#                 Eclipse Public License, Version 1.0                  #
+#                    by AT&T Intellectual Property                     #
+#                                                                      #
+#                A copy of the License is available at                 #
+#          http://www.eclipse.org/org/documents/epl-v10.html           #
+#         (with md5 checksum b35adb5213ca9657e911e9befb180842)         #
+#                                                                      #
+#              Information and Software Systems Research               #
+#                            AT&T Research                             #
+#                           Florham Park NJ                            #
+#                                                                      #
+#                 Glenn Fowler <[email protected]>                  #
+#                                                                      #
+########################################################################
 # non-ksh stub for the nmake silent prefix
 # @(#)silent (AT&T Research) 1992-08-11
 
Only in ksh93/lib/package: CONVERT.mk
diff -upr ksh93.orig/src/cmd/ksh93/Makefile ksh93/src/cmd/ksh93/Makefile
--- ksh93.orig/src/cmd/ksh93/Makefile	2012-01-24 20:22:41.000000000 +0100
+++ ksh93/src/cmd/ksh93/Makefile	2013-02-22 13:09:26.540379476 +0100
@@ -1,6 +1,3 @@
-/*
- * ksh makefile
- */
 
 SH := $(PWD:B:/[0-9]*$//:N=ksh*:-ksh)		/* name of the shell program */
 VERSION = 1.1
@@ -10,10 +7,6 @@ ERROR_CONTEXT_T == Error_context_t /* wo
 RELEASE := $(SH:/.*sh//)
 SHCOMP := shcomp$(RELEASE)
 
-/*
- * set these variables to 1 to enable, 0 to disable, null to probe
- * override SHOPT_foo=1 can be placed one per line in the build dir Makeargs
- */
 
 SHOPT_2DMATCH == 1		/* two dimensional .sh.match for ${var//pat/str} */
 SHOPT_ACCT ==  			/* accounting */
diff -upr ksh93.orig/src/cmd/ksh93/sh/lex.c ksh93/src/cmd/ksh93/sh/lex.c
--- ksh93.orig/src/cmd/ksh93/sh/lex.c	2013-02-22 10:44:19.923019687 +0100
+++ ksh93/src/cmd/ksh93/sh/lex.c	2013-02-22 13:14:55.459595781 +0100
@@ -1540,9 +1540,14 @@ static int comsub(register Lex_t *lp, in
 	register int	line=lp->sh->inlineno;
 	char *first,*cp=fcseek(0),word[5];
 	int off, messages=0, assignok=lp->assignok, csub;
+	struct ionod *heredoc;
 	struct lexstate	save;
 	save = lp->lex;
 	csub = lp->comsub;
+	if(lp->heredoc) {
+		heredoc = lp->heredoc;
+		lp->heredoc = NULL;
+	}
 	sh_lexopen(lp,lp->sh,1);
 	lp->lexd.dolparen++;
 	lp->lex.incase=0;
@@ -1666,6 +1671,9 @@ done:
 	lp->assignok = (endchar(lp)==RBRACT?assignok:0);
 	if(lp->heredoc)
 		errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax5,lp->sh->inlineno,lp->heredoc->ioname);
+	else
+		if(heredoc)
+			lp->heredoc = heredoc;
 	return(messages);
 }
 
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to