aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
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 /shell/ash.c
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
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c70
1 files changed, 58 insertions, 12 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;