You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
3.5 KiB
138 lines
3.5 KiB
3 years ago
|
diff --git a/Fixes b/Fixes
|
||
|
--- a/Fixes
|
||
|
+++ b/Fixes
|
||
|
@@ -2,7 +2,6 @@
|
||
|
4. Don't play pointer tricks that are undefined in modern c (Brooks Davis)
|
||
|
3. Fix out of bounds read (Brooks Davis)
|
||
|
2. Fix type of read in prompt confirmation (eg. rmstar) (David Kaspar)
|
||
|
- 1. PR/471: Delay arginp parsing
|
||
|
|
||
|
20. V6.20.00 - 20161124
|
||
|
19. Don't resize the screen if it did not change size.
|
||
|
diff --git a/sh.c b/sh.c
|
||
|
--- a/sh.c
|
||
|
+++ b/sh.c
|
||
|
@@ -249,7 +249,6 @@ main(int argc, char **argv)
|
||
|
char *tcp, *ttyn;
|
||
|
int f, reenter;
|
||
|
char **tempv;
|
||
|
- const char *targinp = NULL;
|
||
|
int osetintr;
|
||
|
struct sigaction oparintr;
|
||
|
|
||
|
@@ -941,7 +940,30 @@ main(int argc, char **argv)
|
||
|
*p &= ASCII;
|
||
|
}
|
||
|
#endif
|
||
|
- targinp = tempv[0];
|
||
|
+ 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);
|
||
|
+ }
|
||
|
+ }
|
||
|
prompt = 0;
|
||
|
nofile = 1;
|
||
|
break;
|
||
|
@@ -1186,7 +1208,7 @@ main(int argc, char **argv)
|
||
|
sigset_interrupting(SIGXFSZ, queue_phup);
|
||
|
#endif
|
||
|
|
||
|
- if (quitit == 0 && targinp == 0) {
|
||
|
+ if (quitit == 0 && arginp == 0) {
|
||
|
#ifdef SIGTSTP
|
||
|
(void) signal(SIGTSTP, SIG_IGN);
|
||
|
#endif
|
||
|
@@ -1304,7 +1326,7 @@ main(int argc, char **argv)
|
||
|
*/
|
||
|
sigset_interrupting(SIGCHLD, queue_pchild);
|
||
|
|
||
|
- if (intty && !targinp)
|
||
|
+ if (intty && !arginp)
|
||
|
(void) ed_Setup(editing);/* Get the tty state, and set defaults */
|
||
|
/* Only alter the tty state if editing */
|
||
|
|
||
|
@@ -1339,7 +1361,7 @@ main(int argc, char **argv)
|
||
|
#ifdef _PATH_DOTCSHRC
|
||
|
(void) srcfile(_PATH_DOTCSHRC, 0, 0, NULL);
|
||
|
#endif
|
||
|
- if (!targinp && !onelflg && !havhash)
|
||
|
+ if (!arginp && !onelflg && !havhash)
|
||
|
dohash(NULL,NULL);
|
||
|
#ifndef LOGINFIRST
|
||
|
#ifdef _PATH_DOTLOGIN
|
||
|
@@ -1359,7 +1381,7 @@ main(int argc, char **argv)
|
||
|
if (!srccat(varval(STRhome), STRsldottcshrc))
|
||
|
(void) srccat(varval(STRhome), STRsldotcshrc);
|
||
|
|
||
|
- if (!targinp && !onelflg && !havhash)
|
||
|
+ if (!arginp && !onelflg && !havhash)
|
||
|
dohash(NULL,NULL);
|
||
|
|
||
|
/*
|
||
|
@@ -1379,7 +1401,7 @@ main(int argc, char **argv)
|
||
|
exitset--;
|
||
|
|
||
|
/* Initing AFTER .cshrc is the Right Way */
|
||
|
- if (intty && !targinp) { /* PWP setup stuff */
|
||
|
+ if (intty && !arginp) { /* PWP setup stuff */
|
||
|
ed_Init(); /* init the new line editor */
|
||
|
#ifdef SIG_WINDOW
|
||
|
check_window_size(1); /* mung environment */
|
||
|
@@ -1395,37 +1417,6 @@ main(int argc, char **argv)
|
||
|
setNS(STRecho);
|
||
|
|
||
|
|
||
|
- if (targinp) {
|
||
|
- /* If this -c command caused an error before, skip processing */
|
||
|
- if (reenter && arginp) {
|
||
|
- exitcode = 1;
|
||
|
- goto done;
|
||
|
- }
|
||
|
-
|
||
|
- 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
|