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