4ed5641
From b27c203ff06a33b9fa6c0f2e14a8825eb3f672da Mon Sep 17 00:00:00 2001
4ed5641
From: christos <christos>
4ed5641
Date: Sun, 27 Nov 2016 16:40:58 +0000
4ed5641
Subject: [PATCH 1/2] PR/471: Daiki Ueno: Delay interpreting arginp until we've
4ed5641
 processed our startup files (which can change the NLS environment).
4ed5641
4ed5641
---
4ed5641
 sh.c | 62 +++++++++++++++++++++++++++++++++-----------------------------
4ed5641
 1 file changed, 33 insertions(+), 29 deletions(-)
4ed5641
4ed5641
diff --git a/sh.c b/sh.c
4ed5641
index 3b7db65..c73d42d 100644
4ed5641
--- a/sh.c
4ed5641
+++ b/sh.c
4ed5641
@@ -248,6 +248,7 @@ main(int argc, char **argv)
4ed5641
     char *tcp, *ttyn;
4ed5641
     int f, reenter;
4ed5641
     char **tempv;
4ed5641
+    const char *targinp = NULL;
4ed5641
     int osetintr;
4ed5641
     struct sigaction oparintr;
4ed5641
 
4ed5641
@@ -937,30 +938,7 @@ main(int argc, char **argv)
4ed5641
 		      *p &= ASCII;
4ed5641
 		  }
4ed5641
 #endif
4ed5641
-		arginp = SAVE(tempv[0]);
4ed5641
-
4ed5641
-		/*
4ed5641
-		 * we put the command into a variable
4ed5641
-		 */
4ed5641
-		if (arginp != NULL)
4ed5641
-		    setv(STRcommand, quote(Strsave(arginp)), VAR_READWRITE);
4ed5641
-
4ed5641
-		/*
4ed5641
-		 * * Give an error on -c arguments that end in * backslash to
4ed5641
-		 * ensure that you don't make * nonportable csh scripts.
4ed5641
-		 */
4ed5641
-		{
4ed5641
-		    int count;
4ed5641
-
4ed5641
-		    cp = Strend(arginp);
4ed5641
-		    count = 0;
4ed5641
-		    while (cp > arginp && *--cp == '\\')
4ed5641
-			++count;
4ed5641
-		    if ((count & 1) != 0) {
4ed5641
-			exiterr = 1;
4ed5641
-			stderror(ERR_ARGC);
4ed5641
-		    }
4ed5641
-		}
4ed5641
+		targinp = tempv[0];
4ed5641
 		prompt = 0;
4ed5641
 		nofile = 1;
4ed5641
 		break;
4ed5641
@@ -1205,7 +1183,7 @@ main(int argc, char **argv)
4ed5641
 	    sigset_interrupting(SIGXFSZ, queue_phup);
4ed5641
 #endif
4ed5641
 
4ed5641
-	if (quitit == 0 && arginp == 0) {
4ed5641
+	if (quitit == 0 && targinp == 0) {
4ed5641
 #ifdef SIGTSTP
4ed5641
 	    (void) signal(SIGTSTP, SIG_IGN);
4ed5641
 #endif
4ed5641
@@ -1323,7 +1301,7 @@ main(int argc, char **argv)
4ed5641
  */
4ed5641
     sigset_interrupting(SIGCHLD, queue_pchild);
4ed5641
 
4ed5641
-    if (intty && !arginp) 	
4ed5641
+    if (intty && !targinp) 	
4ed5641
 	(void) ed_Setup(editing);/* Get the tty state, and set defaults */
4ed5641
 				 /* Only alter the tty state if editing */
4ed5641
     
4ed5641
@@ -1358,7 +1336,7 @@ main(int argc, char **argv)
4ed5641
 #ifdef _PATH_DOTCSHRC
4ed5641
 	    (void) srcfile(_PATH_DOTCSHRC, 0, 0, NULL);
4ed5641
 #endif
4ed5641
-	    if (!arginp && !onelflg && !havhash)
4ed5641
+	    if (!targinp && !onelflg && !havhash)
4ed5641
 		dohash(NULL,NULL);
4ed5641
 #ifndef LOGINFIRST
4ed5641
 #ifdef _PATH_DOTLOGIN
4ed5641
@@ -1378,7 +1356,7 @@ main(int argc, char **argv)
4ed5641
 	if (!srccat(varval(STRhome), STRsldottcshrc))
4ed5641
 	    (void) srccat(varval(STRhome), STRsldotcshrc);
4ed5641
 
4ed5641
-	if (!arginp && !onelflg && !havhash)
4ed5641
+	if (!targinp && !onelflg && !havhash)
4ed5641
 	    dohash(NULL,NULL);
4ed5641
 
4ed5641
 	/*
4ed5641
@@ -1398,7 +1376,7 @@ main(int argc, char **argv)
4ed5641
     exitset--;
4ed5641
 
4ed5641
     /* Initing AFTER .cshrc is the Right Way */
4ed5641
-    if (intty && !arginp) {	/* PWP setup stuff */
4ed5641
+    if (intty && !targinp) {	/* PWP setup stuff */
4ed5641
 	ed_Init();		/* init the new line editor */
4ed5641
 #ifdef SIG_WINDOW
4ed5641
 	check_window_size(1);	/* mung environment */
4ed5641
@@ -1413,6 +1391,32 @@ main(int argc, char **argv)
4ed5641
     if (nexececho)
4ed5641
 	setNS(STRecho);
4ed5641
     
4ed5641
+
4ed5641
+    if (targinp) {
4ed5641
+	arginp = SAVE(targinp);
4ed5641
+	/*
4ed5641
+	 * we put the command into a variable
4ed5641
+	 */
4ed5641
+	if (arginp != NULL)
4ed5641
+	    setv(STRcommand, quote(Strsave(arginp)), VAR_READWRITE);
4ed5641
+
4ed5641
+	/*
4ed5641
+	 * * Give an error on -c arguments that end in * backslash to
4ed5641
+	 * ensure that you don't make * nonportable csh scripts.
4ed5641
+	 */
4ed5641
+	{
4ed5641
+	    int count;
4ed5641
+
4ed5641
+	    cp = Strend(arginp);
4ed5641
+	    count = 0;
4ed5641
+	    while (cp > arginp && *--cp == '\\')
4ed5641
+		++count;
4ed5641
+	    if ((count & 1) != 0) {
4ed5641
+		exiterr = 1;
4ed5641
+		stderror(ERR_ARGC);
4ed5641
+	    }
4ed5641
+	}
4ed5641
+    }
4ed5641
     /*
4ed5641
      * All the rest of the world is inside this call. The argument to process
4ed5641
      * indicates whether it should catch "error unwinds".  Thus if we are a
4ed5641
-- 
4ed5641
2.7.4
4ed5641
4ed5641
4ed5641
From 517fdacc6e194acfa56aecdb5bbf4cf7b129fbc2 Mon Sep 17 00:00:00 2001
4ed5641
From: christos <christos>
4ed5641
Date: Sun, 27 Nov 2016 16:41:24 +0000
4ed5641
Subject: [PATCH 2/2] mention latest fix
4ed5641
4ed5641
---
4ed5641
 Fixes | 1 +
4ed5641
 1 file changed, 1 insertion(+)
4ed5641
4ed5641
diff --git a/Fixes b/Fixes
4ed5641
index 7440349..c79dc38 100644
4ed5641
--- a/Fixes
4ed5641
+++ b/Fixes
4ed5641
@@ -1,3 +1,4 @@
4ed5641
+ 21. PR/471: Delay arginp parsing
4ed5641
  20. V6.20.00 - 20161124
4ed5641
  19. Don't resize the screen if it did not change size.
4ed5641
  18. V6.19.01 - 20161025
4ed5641
-- 
4ed5641
2.7.4
4ed5641