aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2004-02-04 08:24:39 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2004-02-04 08:24:39 +0000
commit16e45d7e29a35c57fc31484e72f1294144e4899c (patch)
treeece28ef81d8de5930894aa3e9b61f8a64022ec7a
parent31b98dd09748535a5004e948bb560c320d179a66 (diff)
downloadbusybox-w32-16e45d7e29a35c57fc31484e72f1294144e4899c.tar.gz
busybox-w32-16e45d7e29a35c57fc31484e72f1294144e4899c.tar.bz2
busybox-w32-16e45d7e29a35c57fc31484e72f1294144e4899c.zip
Vodz last_patch_125_2, this patch have:
- synced with dash 0.4.21 - better handle trap "cmds..." SIGINT (strange, i make bad hack for ash and cmdedit, but this work only with this...) - may be haven`t problem with Ctrl-D
-rw-r--r--shell/ash.c70
-rw-r--r--shell/cmdedit.c11
2 files changed, 66 insertions, 15 deletions
diff --git a/shell/ash.c b/shell/ash.c
index d488a543f..1fe1e8290 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3476,10 +3476,17 @@ funcdone:
3476} 3476}
3477 3477
3478 3478
3479static inline int
3480goodname(const char *p)
3481{
3482 return !*endofname(p);
3483}
3484
3479/* 3485/*
3480 * Search for a command. This is called before we fork so that the 3486 * Search for a command. This is called before we fork so that the
3481 * location of the command will be available in the parent as well as 3487 * location of the command will be available in the parent as well as
3482 * the child. 3488 * the child. The check for "goodname" is an overly conservative
3489 * check that the name will not be subject to expansion.
3483 */ 3490 */
3484 3491
3485static void 3492static void
@@ -3488,7 +3495,9 @@ prehash(union node *n)
3488 struct cmdentry entry; 3495 struct cmdentry entry;
3489 3496
3490 if (n->type == NCMD && n->ncmd.args) 3497 if (n->type == NCMD && n->ncmd.args)
3491 find_command(n->ncmd.args->narg.text, &entry, 0, pathval()); 3498 if (goodname(n->ncmd.args->narg.text))
3499 find_command(n->ncmd.args->narg.text, &entry, 0,
3500 pathval());
3492} 3501}
3493 3502
3494 3503
@@ -6020,7 +6029,12 @@ retry:
6020 nr = cmdedit_read_input((char *) cmdedit_prompt, buf); 6029 nr = cmdedit_read_input((char *) cmdedit_prompt, buf);
6021 if(nr == 0) { 6030 if(nr == 0) {
6022 /* Ctrl+C presend */ 6031 /* Ctrl+C presend */
6023 raise(SIGINT); 6032 if(trap[SIGINT]) {
6033 buf[0] = '\n';
6034 buf[1] = 0;
6035 raise(SIGINT);
6036 return 1;
6037 }
6024 goto retry; 6038 goto retry;
6025 } 6039 }
6026 if(nr < 0) { 6040 if(nr < 0) {
@@ -7425,6 +7439,8 @@ cmdtxt(union node *n)
7425 const char *p; 7439 const char *p;
7426 char s[2]; 7440 char s[2];
7427 7441
7442 if (!n)
7443 return;
7428 switch (n->type) { 7444 switch (n->type) {
7429 default: 7445 default:
7430#if DEBUG 7446#if DEBUG
@@ -9295,11 +9311,6 @@ static void synerror(const char *) __attribute__((__noreturn__));
9295static void setprompt(int); 9311static void setprompt(int);
9296 9312
9297 9313
9298static inline int
9299goodname(const char *p)
9300{
9301 return !*endofname(p);
9302}
9303 9314
9304static inline int 9315static inline int
9305isassignment(const char *p) 9316isassignment(const char *p)
@@ -10755,7 +10766,7 @@ noexpand(char *text)
10755 * more letters, underscores, and digits). 10766 * more letters, underscores, and digits).
10756 */ 10767 */
10757 10768
10758char * 10769static char *
10759endofname(const char *name) 10770endofname(const char *name)
10760{ 10771{
10761 char *p; 10772 char *p;
@@ -11835,12 +11846,13 @@ exitshell(void)
11835 struct jmploc loc; 11846 struct jmploc loc;
11836 char *p; 11847 char *p;
11837 int status; 11848 int status;
11849 int jmp;
11838 11850
11851 jmp = setjmp(loc.loc);
11839 status = exitstatus; 11852 status = exitstatus;
11840 TRACE(("pid %d, exitshell(%d)\n", getpid(), status)); 11853 TRACE(("pid %d, exitshell(%d)\n", getpid(), status));
11841 if (setjmp(loc.loc)) { 11854 if (jmp)
11842 goto out; 11855 goto out;
11843 }
11844 handler = &loc; 11856 handler = &loc;
11845 if ((p = trap[0]) != NULL && *p != '\0') { 11857 if ((p = trap[0]) != NULL && *p != '\0') {
11846 trap[0] = NULL; 11858 trap[0] = NULL;
@@ -12713,7 +12725,41 @@ ulimitcmd(int argc, char **argv)
12713 struct rlimit limit; 12725 struct rlimit limit;
12714 12726
12715 what = 'f'; 12727 what = 'f';
12716 while ((optc = nextopt("HSatfdsmcnplvw")) != '\0') 12728 while ((optc = nextopt("HSa"
12729#ifdef RLIMIT_CPU
12730 "t"
12731#endif
12732#ifdef RLIMIT_FSIZE
12733 "f"
12734#endif
12735#ifdef RLIMIT_DATA
12736 "d"
12737#endif
12738#ifdef RLIMIT_STACK
12739 "s"
12740#endif
12741#ifdef RLIMIT_CORE
12742 "c"
12743#endif
12744#ifdef RLIMIT_RSS
12745 "m"
12746#endif
12747#ifdef RLIMIT_MEMLOCK
12748 "l"
12749#endif
12750#ifdef RLIMIT_NPROC
12751 "p"
12752#endif
12753#ifdef RLIMIT_NOFILE
12754 "n"
12755#endif
12756#ifdef RLIMIT_AS
12757 "v"
12758#endif
12759#ifdef RLIMIT_LOCKS
12760 "w"
12761#endif
12762 )) != '\0')
12717 switch (optc) { 12763 switch (optc) {
12718 case 'H': 12764 case 'H':
12719 how = HARD; 12765 how = HARD;
diff --git a/shell/cmdedit.c b/shell/cmdedit.c
index f54d5d587..c0fa1b255 100644
--- a/shell/cmdedit.c
+++ b/shell/cmdedit.c
@@ -1283,10 +1283,15 @@ int cmdedit_read_input(char *prompt, char command[BUFSIZ])
1283 case 3: 1283 case 3:
1284 /* Control-c -- stop gathering input */ 1284 /* Control-c -- stop gathering input */
1285 goto_new_line(); 1285 goto_new_line();
1286#ifndef CONFIG_ASH
1286 command[0] = 0; 1287 command[0] = 0;
1287 len = 0; 1288 len = 0;
1288 lastWasTab = FALSE; 1289 lastWasTab = FALSE;
1289 put_prompt(); 1290 put_prompt();
1291#else
1292 len = 0;
1293 break_out = -1; /* for control traps */
1294#endif
1290 break; 1295 break;
1291 case 4: 1296 case 4:
1292 /* Control-d -- Delete one character, or exit 1297 /* Control-d -- Delete one character, or exit
@@ -1299,7 +1304,7 @@ prepare_to_die:
1299 /* cmdedit_reset_term() called in atexit */ 1304 /* cmdedit_reset_term() called in atexit */
1300 exit(EXIT_SUCCESS); 1305 exit(EXIT_SUCCESS);
1301#else 1306#else
1302 break_out = -1; /* for control stoped jobs */ 1307 len = break_out = -1; /* for control stoped jobs */
1303 break; 1308 break;
1304#endif 1309#endif
1305 } else { 1310 } else {
@@ -1493,7 +1498,7 @@ rewrite_line:
1493 /* cleanup may be saved current command line */ 1498 /* cleanup may be saved current command line */
1494 free(history[MAX_HISTORY]); 1499 free(history[MAX_HISTORY]);
1495 history[MAX_HISTORY] = 0; 1500 history[MAX_HISTORY] = 0;
1496 if (len) { /* no put empty line */ 1501 if (len> 0) { /* no put empty line */
1497 int i = n_history; 1502 int i = n_history;
1498 /* After max history, remove the oldest command */ 1503 /* After max history, remove the oldest command */
1499 if (i >= MAX_HISTORY) { 1504 if (i >= MAX_HISTORY) {
@@ -1510,7 +1515,7 @@ rewrite_line:
1510 } 1515 }
1511#else /* MAX_HISTORY < 1 */ 1516#else /* MAX_HISTORY < 1 */
1512#if defined(CONFIG_FEATURE_SH_FANCY_PROMPT) 1517#if defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
1513 if (len) { /* no put empty line */ 1518 if (len > 0) { /* no put empty line */
1514 num_ok_lines++; 1519 num_ok_lines++;
1515 } 1520 }
1516#endif 1521#endif