aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-03-15 08:29:22 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-03-15 08:29:22 +0000
commitb16674f3c1a961e0b5d6a57745f5f749d95c641e (patch)
tree4c6d2217f4d8306c59cf1096f8664e1cfd167213 /shell
parente7135df4a650f9197b633784472f45602524855b (diff)
downloadbusybox-w32-b16674f3c1a961e0b5d6a57745f5f749d95c641e.tar.gz
busybox-w32-b16674f3c1a961e0b5d6a57745f5f749d95c641e.tar.bz2
busybox-w32-b16674f3c1a961e0b5d6a57745f5f749d95c641e.zip
Remove trailing whitespace. Update copyright to include 2004.
git-svn-id: svn://busybox.net/trunk/busybox@8630 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r--shell/Config.in2
-rw-r--r--shell/Makefile2
-rw-r--r--shell/Makefile.in2
-rw-r--r--shell/ash.c2
-rw-r--r--shell/hush.c112
-rw-r--r--shell/lash.c6
-rw-r--r--shell/msh.c54
7 files changed, 90 insertions, 90 deletions
diff --git a/shell/Config.in b/shell/Config.in
index 892b96e78..bcb5e719b 100644
--- a/shell/Config.in
+++ b/shell/Config.in
@@ -41,7 +41,7 @@ config CONFIG_ASH
41 the most complete and most pedantically correct shell included with 41 the most complete and most pedantically correct shell included with
42 busybox. This shell is actually a derivative of the Debian 'dash' 42 busybox. This shell is actually a derivative of the Debian 'dash'
43 shell (by Herbert Xu), which was created by porting the 'ash' shell 43 shell (by Herbert Xu), which was created by porting the 'ash' shell
44 (written by Kenneth Almquist) from NetBSD. 44 (written by Kenneth Almquist) from NetBSD.
45 45
46comment "Ash Shell Options" 46comment "Ash Shell Options"
47 depends on CONFIG_ASH 47 depends on CONFIG_ASH
diff --git a/shell/Makefile b/shell/Makefile
index a08219262..8f476c19e 100644
--- a/shell/Makefile
+++ b/shell/Makefile
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
diff --git a/shell/Makefile.in b/shell/Makefile.in
index c5be7ba79..7b9f41ed4 100644
--- a/shell/Makefile.in
+++ b/shell/Makefile.in
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
diff --git a/shell/ash.c b/shell/ash.c
index 8c2493ece..060860c07 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7615,7 +7615,7 @@ cmdputs(const char *s)
7615 int quoted = 0; 7615 int quoted = 0;
7616 static const char *const vstype[16] = { 7616 static const char *const vstype[16] = {
7617 nullstr, "}", "-", "+", "?", "=", 7617 nullstr, "}", "-", "+", "?", "=",
7618 "%", "%%", "#", "##", nullstr 7618 "%", "%%", "#", "##", nullstr
7619 }; 7619 };
7620 7620
7621 nextc = makestrspace((strlen(s) + 1) * 8, cmdnextc); 7621 nextc = makestrspace((strlen(s) + 1) * 8, cmdnextc);
diff --git a/shell/hush.c b/shell/hush.c
index 84818ffa3..5da975746 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -12,7 +12,7 @@
12 * written Dec 2000 and Jan 2001 by Larry Doolittle. The 12 * written Dec 2000 and Jan 2001 by Larry Doolittle. The
13 * execution engine, the builtins, and much of the underlying 13 * execution engine, the builtins, and much of the underlying
14 * support has been adapted from busybox-0.49pre's lash, which is 14 * support has been adapted from busybox-0.49pre's lash, which is
15 * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 15 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
16 * written by Erik Andersen <andersen@codepoet.org>. That, in turn, 16 * written by Erik Andersen <andersen@codepoet.org>. That, in turn,
17 * is based in part on ladsh.c, by Michael K. Johnson and Erik W. 17 * is based in part on ladsh.c, by Michael K. Johnson and Erik W.
18 * Troan, which they placed in the public domain. I don't know 18 * Troan, which they placed in the public domain. I don't know
@@ -197,7 +197,7 @@ struct redir_struct {
197 redir_type type; /* type of redirection */ 197 redir_type type; /* type of redirection */
198 int fd; /* file descriptor being redirected */ 198 int fd; /* file descriptor being redirected */
199 int dup; /* -1, or file descriptor being duplicated */ 199 int dup; /* -1, or file descriptor being duplicated */
200 struct redir_struct *next; /* pointer to the next redirect in the list */ 200 struct redir_struct *next; /* pointer to the next redirect in the list */
201 glob_t word; /* *word.gl_pathv is the filename */ 201 glob_t word; /* *word.gl_pathv is the filename */
202}; 202};
203 203
@@ -248,7 +248,7 @@ char **global_argv;
248unsigned int global_argc; 248unsigned int global_argc;
249unsigned int last_return_code; 249unsigned int last_return_code;
250extern char **environ; /* This is in <unistd.h>, but protected with __USE_GNU */ 250extern char **environ; /* This is in <unistd.h>, but protected with __USE_GNU */
251 251
252/* "globals" within this file */ 252/* "globals" within this file */
253static char *ifs; 253static char *ifs;
254static char map[256]; 254static char map[256];
@@ -421,7 +421,7 @@ static struct built_in_command bltins[] = {
421 {"continue", "Continue for, while or until loop", builtin_not_written}, 421 {"continue", "Continue for, while or until loop", builtin_not_written},
422 {"env", "Print all environment variables", builtin_env}, 422 {"env", "Print all environment variables", builtin_env},
423 {"eval", "Construct and run shell command", builtin_eval}, 423 {"eval", "Construct and run shell command", builtin_eval},
424 {"exec", "Exec command, replacing this shell with the exec'd process", 424 {"exec", "Exec command, replacing this shell with the exec'd process",
425 builtin_exec}, 425 builtin_exec},
426 {"exit", "Exit from shell()", builtin_exit}, 426 {"exit", "Exit from shell()", builtin_exit},
427 {"export", "Set environment variable", builtin_export}, 427 {"export", "Set environment variable", builtin_export},
@@ -456,10 +456,10 @@ static int builtin_eval(struct child_prog *child)
456{ 456{
457 char *str = NULL; 457 char *str = NULL;
458 int rcode = EXIT_SUCCESS; 458 int rcode = EXIT_SUCCESS;
459 459
460 if (child->argv[1]) { 460 if (child->argv[1]) {
461 str = make_string(child->argv + 1); 461 str = make_string(child->argv + 1);
462 parse_string_outer(str, FLAG_EXIT_FROM_LOOP | 462 parse_string_outer(str, FLAG_EXIT_FROM_LOOP |
463 FLAG_PARSE_SEMICOLON); 463 FLAG_PARSE_SEMICOLON);
464 free(str); 464 free(str);
465 rcode = last_return_code; 465 rcode = last_return_code;
@@ -873,7 +873,7 @@ static inline void cmdedit_set_initial_prompt(void)
873 PS1 = getenv("PS1"); 873 PS1 = getenv("PS1");
874 if(PS1==0) 874 if(PS1==0)
875 PS1 = "\\w \\$ "; 875 PS1 = "\\w \\$ ";
876#endif 876#endif
877} 877}
878 878
879static inline void setup_prompt_string(int promptmode, char **prompt_str) 879static inline void setup_prompt_string(int promptmode, char **prompt_str)
@@ -919,7 +919,7 @@ static void get_user_input(struct in_str *i)
919 i->p = the_command; 919 i->p = the_command;
920} 920}
921 921
922/* This is the magic location that prints prompts 922/* This is the magic location that prints prompts
923 * and gets data back from the user */ 923 * and gets data back from the user */
924static int file_get(struct in_str *i) 924static int file_get(struct in_str *i)
925{ 925{
@@ -1110,14 +1110,14 @@ static void pseudo_exec(struct child_prog *child)
1110 } 1110 }
1111 1111
1112 /* Check if the command matches any busybox internal commands 1112 /* Check if the command matches any busybox internal commands
1113 * ("applets") here. 1113 * ("applets") here.
1114 * FIXME: This feature is not 100% safe, since 1114 * FIXME: This feature is not 100% safe, since
1115 * BusyBox is not fully reentrant, so we have no guarantee the things 1115 * BusyBox is not fully reentrant, so we have no guarantee the things
1116 * from the .bss are still zeroed, or that things from .data are still 1116 * from the .bss are still zeroed, or that things from .data are still
1117 * at their defaults. We could exec ourself from /proc/self/exe, but I 1117 * at their defaults. We could exec ourself from /proc/self/exe, but I
1118 * really dislike relying on /proc for things. We could exec ourself 1118 * really dislike relying on /proc for things. We could exec ourself
1119 * from global_argv[0], but if we are in a chroot, we may not be able 1119 * from global_argv[0], but if we are in a chroot, we may not be able
1120 * to find ourself... */ 1120 * to find ourself... */
1121#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL 1121#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
1122 { 1122 {
1123 int argc_l; 1123 int argc_l;
@@ -1196,7 +1196,7 @@ static void insert_bg_job(struct pipe *pi)
1196 } 1196 }
1197 } 1197 }
1198 1198
1199 /* we don't wait for background thejobs to return -- append it 1199 /* we don't wait for background thejobs to return -- append it
1200 to the list of backgrounded thejobs and leave it alone */ 1200 to the list of backgrounded thejobs and leave it alone */
1201 printf("[%d] %d\n", thejob->jobid, thejob->progs[0].pid); 1201 printf("[%d] %d\n", thejob->jobid, thejob->progs[0].pid);
1202 last_bg_pid = thejob->progs[0].pid; 1202 last_bg_pid = thejob->progs[0].pid;
@@ -1226,7 +1226,7 @@ static void remove_bg_job(struct pipe *pi)
1226 free(pi); 1226 free(pi);
1227} 1227}
1228 1228
1229/* Checks to see if any processes have exited -- if they 1229/* Checks to see if any processes have exited -- if they
1230 have, figure out why and see if a job has completed */ 1230 have, figure out why and see if a job has completed */
1231static int checkjobs(struct pipe* fg_pipe) 1231static int checkjobs(struct pipe* fg_pipe)
1232{ 1232{
@@ -1246,7 +1246,7 @@ static int checkjobs(struct pipe* fg_pipe)
1246 int i, rcode = 0; 1246 int i, rcode = 0;
1247 for (i=0; i < fg_pipe->num_progs; i++) { 1247 for (i=0; i < fg_pipe->num_progs; i++) {
1248 if (fg_pipe->progs[i].pid == childpid) { 1248 if (fg_pipe->progs[i].pid == childpid) {
1249 if (i==fg_pipe->num_progs-1) 1249 if (i==fg_pipe->num_progs-1)
1250 rcode=WEXITSTATUS(status); 1250 rcode=WEXITSTATUS(status);
1251 (fg_pipe->num_progs)--; 1251 (fg_pipe->num_progs)--;
1252 return(rcode); 1252 return(rcode);
@@ -1289,7 +1289,7 @@ static int checkjobs(struct pipe* fg_pipe)
1289 if (pi->stopped_progs == pi->num_progs) { 1289 if (pi->stopped_progs == pi->num_progs) {
1290 printf("\n"JOB_STATUS_FORMAT, pi->jobid, "Stopped", pi->text); 1290 printf("\n"JOB_STATUS_FORMAT, pi->jobid, "Stopped", pi->text);
1291 } 1291 }
1292#endif 1292#endif
1293 } 1293 }
1294 } 1294 }
1295 1295
@@ -1378,7 +1378,7 @@ static int run_pipe_real(struct pipe *pi)
1378 /* Ok, this case is tricky. We have to decide if this is a 1378 /* Ok, this case is tricky. We have to decide if this is a
1379 * local variable, or an already exported variable. If it is 1379 * local variable, or an already exported variable. If it is
1380 * already exported, we have to export the new value. If it is 1380 * already exported, we have to export the new value. If it is
1381 * not exported, we need only set this as a local variable. 1381 * not exported, we need only set this as a local variable.
1382 * This junk is all to decide whether or not to export this 1382 * This junk is all to decide whether or not to export this
1383 * variable. */ 1383 * variable. */
1384 int export_me=0; 1384 int export_me=0;
@@ -1408,7 +1408,7 @@ static int run_pipe_real(struct pipe *pi)
1408 } 1408 }
1409 if (child->sp) { 1409 if (child->sp) {
1410 char * str = NULL; 1410 char * str = NULL;
1411 1411
1412 str = make_string((child->argv + i)); 1412 str = make_string((child->argv + i));
1413 parse_string_outer(str, FLAG_EXIT_FROM_LOOP | FLAG_REPARSING); 1413 parse_string_outer(str, FLAG_EXIT_FROM_LOOP | FLAG_REPARSING);
1414 free(str); 1414 free(str);
@@ -1454,7 +1454,7 @@ static int run_pipe_real(struct pipe *pi)
1454#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__) 1454#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__)
1455 if (!(child->pid = fork())) 1455 if (!(child->pid = fork()))
1456#else 1456#else
1457 if (!(child->pid = vfork())) 1457 if (!(child->pid = vfork()))
1458#endif 1458#endif
1459 { 1459 {
1460 /* Set the handling for job control signals back to the default. */ 1460 /* Set the handling for job control signals back to the default. */
@@ -1465,7 +1465,7 @@ static int run_pipe_real(struct pipe *pi)
1465 signal(SIGTTIN, SIG_DFL); 1465 signal(SIGTTIN, SIG_DFL);
1466 signal(SIGTTOU, SIG_DFL); 1466 signal(SIGTTOU, SIG_DFL);
1467 signal(SIGCHLD, SIG_DFL); 1467 signal(SIGCHLD, SIG_DFL);
1468 1468
1469 close_all(); 1469 close_all();
1470 1470
1471 if (nextin != 0) { 1471 if (nextin != 0) {
@@ -1497,7 +1497,7 @@ static int run_pipe_real(struct pipe *pi)
1497 1497
1498 pseudo_exec(child); 1498 pseudo_exec(child);
1499 } 1499 }
1500 1500
1501 1501
1502 /* put our child in the process group whose leader is the 1502 /* put our child in the process group whose leader is the
1503 first process in this pipe */ 1503 first process in this pipe */
@@ -1513,7 +1513,7 @@ static int run_pipe_real(struct pipe *pi)
1513 if (nextout != 1) 1513 if (nextout != 1)
1514 close(nextout); 1514 close(nextout);
1515 1515
1516 /* If there isn't another process, nextin is garbage 1516 /* If there isn't another process, nextin is garbage
1517 but it doesn't matter */ 1517 but it doesn't matter */
1518 nextin = pipefds[0]; 1518 nextin = pipefds[0];
1519 } 1519 }
@@ -1539,12 +1539,12 @@ static int run_list_real(struct pipe *pi)
1539 (rpipe->next == NULL)) { 1539 (rpipe->next == NULL)) {
1540 syntax(); 1540 syntax();
1541 return 1; 1541 return 1;
1542 } 1542 }
1543 if ((rpipe->r_mode == RES_IN && 1543 if ((rpipe->r_mode == RES_IN &&
1544 (rpipe->next->r_mode == RES_IN && 1544 (rpipe->next->r_mode == RES_IN &&
1545 rpipe->next->progs->argv != NULL))|| 1545 rpipe->next->progs->argv != NULL))||
1546 (rpipe->r_mode == RES_FOR && 1546 (rpipe->r_mode == RES_FOR &&
1547 rpipe->next->r_mode != RES_IN)) { 1547 rpipe->next->r_mode != RES_IN)) {
1548 syntax(); 1548 syntax();
1549 return 1; 1549 return 1;
1550 } 1550 }
@@ -1572,7 +1572,7 @@ static int run_list_real(struct pipe *pi)
1572 if (rmode == RES_ELIF && !if_code) continue; 1572 if (rmode == RES_ELIF && !if_code) continue;
1573 if (rmode == RES_FOR && pi->num_progs) { 1573 if (rmode == RES_FOR && pi->num_progs) {
1574 if (!list) { 1574 if (!list) {
1575 /* if no variable values after "in" we skip "for" */ 1575 /* if no variable values after "in" we skip "for" */
1576 if (!pi->next->progs->argv) continue; 1576 if (!pi->next->progs->argv) continue;
1577 /* create list of variable values */ 1577 /* create list of variable values */
1578 list = make_list_in(pi->next->progs->argv, 1578 list = make_list_in(pi->next->progs->argv,
@@ -1581,7 +1581,7 @@ static int run_list_real(struct pipe *pi)
1581 save_name = pi->progs->argv[0]; 1581 save_name = pi->progs->argv[0];
1582 pi->progs->argv[0] = NULL; 1582 pi->progs->argv[0] = NULL;
1583 flag_rep = 1; 1583 flag_rep = 1;
1584 } 1584 }
1585 if (!(*list)) { 1585 if (!(*list)) {
1586 free(pi->progs->argv[0]); 1586 free(pi->progs->argv[0]);
1587 free(save_list); 1587 free(save_list);
@@ -1591,26 +1591,26 @@ static int run_list_real(struct pipe *pi)
1591 pi->progs->glob_result.gl_pathv[0] = 1591 pi->progs->glob_result.gl_pathv[0] =
1592 pi->progs->argv[0]; 1592 pi->progs->argv[0];
1593 continue; 1593 continue;
1594 } else { 1594 } else {
1595 /* insert new value from list for variable */ 1595 /* insert new value from list for variable */
1596 if (pi->progs->argv[0]) 1596 if (pi->progs->argv[0])
1597 free(pi->progs->argv[0]); 1597 free(pi->progs->argv[0]);
1598 pi->progs->argv[0] = *list++; 1598 pi->progs->argv[0] = *list++;
1599 pi->progs->glob_result.gl_pathv[0] = 1599 pi->progs->glob_result.gl_pathv[0] =
1600 pi->progs->argv[0]; 1600 pi->progs->argv[0];
1601 } 1601 }
1602 } 1602 }
1603 if (rmode == RES_IN) continue; 1603 if (rmode == RES_IN) continue;
1604 if (rmode == RES_DO) { 1604 if (rmode == RES_DO) {
1605 if (!flag_rep) continue; 1605 if (!flag_rep) continue;
1606 } 1606 }
1607 if ((rmode == RES_DONE)) { 1607 if ((rmode == RES_DONE)) {
1608 if (flag_rep) { 1608 if (flag_rep) {
1609 flag_restore = 1; 1609 flag_restore = 1;
1610 } else { 1610 } else {
1611 rpipe = NULL; 1611 rpipe = NULL;
1612 } 1612 }
1613 } 1613 }
1614 if (pi->num_progs == 0) continue; 1614 if (pi->num_progs == 0) continue;
1615 save_num_progs = pi->num_progs; /* save number of programs */ 1615 save_num_progs = pi->num_progs; /* save number of programs */
1616 rcode = run_pipe_real(pi); 1616 rcode = run_pipe_real(pi);
@@ -1642,9 +1642,9 @@ static int run_list_real(struct pipe *pi)
1642 pi->num_progs = save_num_progs; /* restore number of programs */ 1642 pi->num_progs = save_num_progs; /* restore number of programs */
1643 if ( rmode == RES_IF || rmode == RES_ELIF ) 1643 if ( rmode == RES_IF || rmode == RES_ELIF )
1644 next_if_code=rcode; /* can be overwritten a number of times */ 1644 next_if_code=rcode; /* can be overwritten a number of times */
1645 if (rmode == RES_WHILE) 1645 if (rmode == RES_WHILE)
1646 flag_rep = !last_return_code; 1646 flag_rep = !last_return_code;
1647 if (rmode == RES_UNTIL) 1647 if (rmode == RES_UNTIL)
1648 flag_rep = last_return_code; 1648 flag_rep = last_return_code;
1649 if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) || 1649 if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) ||
1650 (rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) ) 1650 (rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) )
@@ -1723,7 +1723,7 @@ static int free_pipe_list(struct pipe *head, int indent)
1723 pi->next=NULL; 1723 pi->next=NULL;
1724 free(pi); 1724 free(pi);
1725 } 1725 }
1726 return rcode; 1726 return rcode;
1727} 1727}
1728 1728
1729/* Select which version we will use */ 1729/* Select which version we will use */
@@ -1732,7 +1732,7 @@ static int run_list(struct pipe *pi)
1732 int rcode=0; 1732 int rcode=0;
1733 if (fake_mode==0) { 1733 if (fake_mode==0) {
1734 rcode = run_list_real(pi); 1734 rcode = run_list_real(pi);
1735 } 1735 }
1736 /* free_pipe_list has the side effect of clearing memory 1736 /* free_pipe_list has the side effect of clearing memory
1737 * In the long run that function can be merged with run_list_real, 1737 * In the long run that function can be merged with run_list_real,
1738 * but doing that now would hobble the debugging effort. */ 1738 * but doing that now would hobble the debugging effort. */
@@ -1862,7 +1862,7 @@ static int set_local_var(const char *s, int flg_export)
1862 1862
1863 /* Assume when we enter this function that we are already in 1863 /* Assume when we enter this function that we are already in
1864 * NAME=VALUE format. So the first order of business is to 1864 * NAME=VALUE format. So the first order of business is to
1865 * split 's' on the '=' into 'name' and 'value' */ 1865 * split 's' on the '=' into 'name' and 'value' */
1866 value = strchr(name, '='); 1866 value = strchr(name, '=');
1867 if (value==0 && ++value==0) { 1867 if (value==0 && ++value==0) {
1868 free(name); 1868 free(name);
@@ -1991,7 +1991,7 @@ static int setup_redirect(struct p_context *ctx, int fd, redir_type style,
1991 1991
1992 debug_printf("Redirect type %d%s\n", redir->fd, redir_table[style].descrip); 1992 debug_printf("Redirect type %d%s\n", redir->fd, redir_table[style].descrip);
1993 1993
1994 /* Check for a '2>&1' type redirect */ 1994 /* Check for a '2>&1' type redirect */
1995 redir->dup = redirect_dup_num(input); 1995 redir->dup = redirect_dup_num(input);
1996 if (redir->dup == -2) return 1; /* syntax error */ 1996 if (redir->dup == -2) return 1; /* syntax error */
1997 if (redir->dup != -1) { 1997 if (redir->dup != -1) {
@@ -2377,9 +2377,9 @@ static int parse_group(o_string *dest, struct p_context *ctx,
2377static char *lookup_param(char *src) 2377static char *lookup_param(char *src)
2378{ 2378{
2379 char *p=NULL; 2379 char *p=NULL;
2380 if (src) { 2380 if (src) {
2381 p = getenv(src); 2381 p = getenv(src);
2382 if (!p) 2382 if (!p)
2383 p = get_local_var(src); 2383 p = get_local_var(src);
2384 } 2384 }
2385 return p; 2385 return p;
@@ -2499,7 +2499,7 @@ int parse_stream(o_string *dest, struct p_context *ctx,
2499 if (m==2) { /* unquoted IFS */ 2499 if (m==2) { /* unquoted IFS */
2500 if (done_word(dest, ctx)) { 2500 if (done_word(dest, ctx)) {
2501 return 1; 2501 return 1;
2502 } 2502 }
2503 /* If we aren't performing a substitution, treat a newline as a 2503 /* If we aren't performing a substitution, treat a newline as a
2504 * command separator. */ 2504 * command separator. */
2505 if (end_trigger != '\0' && ch=='\n') 2505 if (end_trigger != '\0' && ch=='\n')
@@ -2624,7 +2624,7 @@ int parse_stream(o_string *dest, struct p_context *ctx,
2624 } 2624 }
2625 /* complain if quote? No, maybe we just finished a command substitution 2625 /* complain if quote? No, maybe we just finished a command substitution
2626 * that was quoted. Example: 2626 * that was quoted. Example:
2627 * $ echo "`cat foo` plus more" 2627 * $ echo "`cat foo` plus more"
2628 * and we just got the EOF generated by the subshell that ran "cat foo" 2628 * and we just got the EOF generated by the subshell that ran "cat foo"
2629 * The only real complaint is if we got an EOF when end_trigger != '\0', 2629 * The only real complaint is if we got an EOF when end_trigger != '\0',
2630 * that is, we were really supposed to get end_trigger, and never got 2630 * that is, we were really supposed to get end_trigger, and never got
@@ -2684,7 +2684,7 @@ int parse_stream_outer(struct in_str *inp, int flag)
2684 if (ctx.old_flag != 0) { 2684 if (ctx.old_flag != 0) {
2685 free(ctx.stack); 2685 free(ctx.stack);
2686 b_reset(&temp); 2686 b_reset(&temp);
2687 } 2687 }
2688 temp.nonnull = 0; 2688 temp.nonnull = 0;
2689 temp.quote = 0; 2689 temp.quote = 0;
2690 inp->p = NULL; 2690 inp->p = NULL;
@@ -2748,9 +2748,9 @@ int hush_main(int argc, char **argv)
2748 /* XXX what should these be while sourcing /etc/profile? */ 2748 /* XXX what should these be while sourcing /etc/profile? */
2749 global_argc = argc; 2749 global_argc = argc;
2750 global_argv = argv; 2750 global_argv = argv;
2751 2751
2752 /* (re?) initialize globals. Sometimes hush_main() ends up calling 2752 /* (re?) initialize globals. Sometimes hush_main() ends up calling
2753 * hush_main(), therefore we cannot rely on the BSS to zero out this 2753 * hush_main(), therefore we cannot rely on the BSS to zero out this
2754 * stuff. Reset these to 0 every time. */ 2754 * stuff. Reset these to 0 every time. */
2755 ifs = NULL; 2755 ifs = NULL;
2756 /* map[] is taken care of with call to update_ifs_map() */ 2756 /* map[] is taken care of with call to update_ifs_map() */
@@ -2770,7 +2770,7 @@ int hush_main(int argc, char **argv)
2770#endif 2770#endif
2771 PS2 = "> "; 2771 PS2 = "> ";
2772 2772
2773 /* initialize our shell local variables with the values 2773 /* initialize our shell local variables with the values
2774 * currently living in the environment */ 2774 * currently living in the environment */
2775 if (e) { 2775 if (e) {
2776 for (; *e; e++) 2776 for (; *e; e++)
@@ -2790,7 +2790,7 @@ int hush_main(int argc, char **argv)
2790 } 2790 }
2791 } 2791 }
2792 input=stdin; 2792 input=stdin;
2793 2793
2794 while ((opt = getopt(argc, argv, "c:xif")) > 0) { 2794 while ((opt = getopt(argc, argv, "c:xif")) > 0) {
2795 switch (opt) { 2795 switch (opt) {
2796 case 'c': 2796 case 'c':
@@ -2832,13 +2832,13 @@ int hush_main(int argc, char **argv)
2832 debug_printf("\ninteractive=%d\n", interactive); 2832 debug_printf("\ninteractive=%d\n", interactive);
2833 if (interactive) { 2833 if (interactive) {
2834 /* Looks like they want an interactive shell */ 2834 /* Looks like they want an interactive shell */
2835#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET 2835#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
2836 printf( "\n\n" BB_BANNER " hush - the humble shell v0.01 (testing)\n"); 2836 printf( "\n\n" BB_BANNER " hush - the humble shell v0.01 (testing)\n");
2837 printf( "Enter 'help' for a list of built-in commands.\n\n"); 2837 printf( "Enter 'help' for a list of built-in commands.\n\n");
2838#endif 2838#endif
2839 setup_job_control(); 2839 setup_job_control();
2840 } 2840 }
2841 2841
2842 if (argv[optind]==NULL) { 2842 if (argv[optind]==NULL) {
2843 opt=parse_file_outer(stdin); 2843 opt=parse_file_outer(stdin);
2844 goto final_return; 2844 goto final_return;
@@ -2877,7 +2877,7 @@ static char *insert_var_value(char *inp)
2877 int len; 2877 int len;
2878 int done = 0; 2878 int done = 0;
2879 char *p, *p1, *res_str = NULL; 2879 char *p, *p1, *res_str = NULL;
2880 2880
2881 while ((p = strchr(inp, SPECIAL_VAR_SYMBOL))) { 2881 while ((p = strchr(inp, SPECIAL_VAR_SYMBOL))) {
2882 if (p != inp) { 2882 if (p != inp) {
2883 len = p - inp; 2883 len = p - inp;
@@ -2893,7 +2893,7 @@ static char *insert_var_value(char *inp)
2893 res_str = xrealloc(res_str, (1 + len)); 2893 res_str = xrealloc(res_str, (1 + len));
2894 strcpy((res_str + res_str_len), p1); 2894 strcpy((res_str + res_str_len), p1);
2895 res_str_len = len; 2895 res_str_len = len;
2896 } 2896 }
2897 *p = SPECIAL_VAR_SYMBOL; 2897 *p = SPECIAL_VAR_SYMBOL;
2898 inp = ++p; 2898 inp = ++p;
2899 done = 1; 2899 done = 1;
@@ -2915,8 +2915,8 @@ static char **make_list_in(char **inp, char *name)
2915 int n = 0; 2915 int n = 0;
2916 char **list; 2916 char **list;
2917 char *p1, *p2, *p3; 2917 char *p1, *p2, *p3;
2918 2918
2919 /* create list of variable values */ 2919 /* create list of variable values */
2920 list = xmalloc(sizeof(*list)); 2920 list = xmalloc(sizeof(*list));
2921 for (i = 0; inp[i]; i++) { 2921 for (i = 0; inp[i]; i++) {
2922 p3 = insert_var_value(inp[i]); 2922 p3 = insert_var_value(inp[i]);
@@ -2928,13 +2928,13 @@ static char **make_list_in(char **inp, char *name)
2928 } 2928 }
2929 if ((p2 = strchr(p1, ' '))) { 2929 if ((p2 = strchr(p1, ' '))) {
2930 len = p2 - p1; 2930 len = p2 - p1;
2931 } else { 2931 } else {
2932 len = strlen(p1); 2932 len = strlen(p1);
2933 p2 = p1 + len; 2933 p2 = p1 + len;
2934 } 2934 }
2935 /* we use n + 2 in realloc for list,because we add 2935 /* we use n + 2 in realloc for list,because we add
2936 * new element and then we will add NULL element */ 2936 * new element and then we will add NULL element */
2937 list = xrealloc(list, sizeof(*list) * (n + 2)); 2937 list = xrealloc(list, sizeof(*list) * (n + 2));
2938 list[n] = xmalloc(2 + name_len + len); 2938 list[n] = xmalloc(2 + name_len + len);
2939 strcpy(list[n], name); 2939 strcpy(list[n], name);
2940 strcat(list[n], "="); 2940 strcat(list[n], "=");
@@ -2946,7 +2946,7 @@ static char **make_list_in(char **inp, char *name)
2946 } 2946 }
2947 list[n] = NULL; 2947 list[n] = NULL;
2948 return list; 2948 return list;
2949} 2949}
2950 2950
2951/* Make new string for parser */ 2951/* Make new string for parser */
2952static char * make_string(char ** inp) 2952static char * make_string(char ** inp)
diff --git a/shell/lash.c b/shell/lash.c
index e4b1b129f..d2d4298fb 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -2,7 +2,7 @@
2/* 2/*
3 * lash -- the BusyBox Lame-Ass SHell 3 * lash -- the BusyBox Lame-Ass SHell
4 * 4 *
5 * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * Based in part on ladsh.c by Michael K. Johnson and Erik W. Troan, which is 7 * Based in part on ladsh.c by Michael K. Johnson and Erik W. Troan, which is
8 * under the following liberal license: "We have placed this source code in the 8 * under the following liberal license: "We have placed this source code in the
@@ -927,7 +927,7 @@ static int expand_arguments(char *command)
927 927
928 } 928 }
929 if (var) { 929 if (var) {
930 /* a single character construction was found, and 930 /* a single character construction was found, and
931 * already handled in the case statement */ 931 * already handled in the case statement */
932 src=dst+2; 932 src=dst+2;
933 } else { 933 } else {
@@ -1093,7 +1093,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
1093 1093
1094 prog->redirects[i].fd = -1; 1094 prog->redirects[i].fd = -1;
1095 if (buf != prog->argv[argc_l]) { 1095 if (buf != prog->argv[argc_l]) {
1096 /* the stuff before this character may be the file number 1096 /* the stuff before this character may be the file number
1097 being redirected */ 1097 being redirected */
1098 prog->redirects[i].fd = 1098 prog->redirects[i].fd =
1099 strtol(prog->argv[argc_l], &chptr, 10); 1099 strtol(prog->argv[argc_l], &chptr, 10);
diff --git a/shell/msh.c b/shell/msh.c
index 31dd04f3e..e7059507a 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -23,7 +23,7 @@
23 * You should have received a copy of the GNU General Public License 23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * 26 *
27 * Original copyright notice is retained at the end of this file. 27 * Original copyright notice is retained at the end of this file.
28 */ 28 */
29 29
@@ -770,7 +770,7 @@ extern int msh_main(int argc, char **argv)
770 if (--argc > 0) 770 if (--argc > 0)
771 PUSHIO(aword, *++argv, iof = nlchar); 771 PUSHIO(aword, *++argv, iof = nlchar);
772 break; 772 break;
773 773
774 case 'q': 774 case 'q':
775 qflag = SIG_DFL; 775 qflag = SIG_DFL;
776 break; 776 break;
@@ -784,7 +784,7 @@ extern int msh_main(int argc, char **argv)
784 setval(prompt, ""); 784 setval(prompt, "");
785 iof = linechar; 785 iof = linechar;
786 break; 786 break;
787 787
788 case 'i': 788 case 'i':
789 interactive++; 789 interactive++;
790 default: 790 default:
@@ -809,7 +809,7 @@ extern int msh_main(int argc, char **argv)
809 PUSHIO(afile, 0, iof); 809 PUSHIO(afile, 0, iof);
810 if (isatty(0) && isatty(1) && !cflag) { 810 if (isatty(0) && isatty(1) && !cflag) {
811 interactive++; 811 interactive++;
812#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET 812#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
813 printf( "\n\n" BB_BANNER " Built-in shell (msh)\n"); 813 printf( "\n\n" BB_BANNER " Built-in shell (msh)\n");
814 printf( "Enter 'help' for a list of built-in commands.\n\n"); 814 printf( "Enter 'help' for a list of built-in commands.\n\n");
815#endif 815#endif
@@ -838,7 +838,7 @@ extern int msh_main(int argc, char **argv)
838 ap++; 838 ap++;
839 } 839 }
840 } 840 }
841 } 841 }
842 setval(lookup("#"), putn((--dolc < 0) ? (dolc = 0) : dolc)); 842 setval(lookup("#"), putn((--dolc < 0) ? (dolc = 0) : dolc));
843 843
844 for (;;) { 844 for (;;) {
@@ -2303,7 +2303,7 @@ int act;
2303#if __GNUC__ 2303#if __GNUC__
2304 /* Avoid longjmp clobbering */ 2304 /* Avoid longjmp clobbering */
2305 (void) &wp; 2305 (void) &wp;
2306#endif 2306#endif
2307 2307
2308 2308
2309 if (t == NULL) 2309 if (t == NULL)
@@ -2318,7 +2318,7 @@ int act;
2318 case TPAREN: 2318 case TPAREN:
2319 rv = execute(t->left, pin, pout, 0); 2319 rv = execute(t->left, pin, pout, 0);
2320 break; 2320 break;
2321 2321
2322 case TCOM: 2322 case TCOM:
2323 { 2323 {
2324 int child; 2324 int child;
@@ -2395,7 +2395,7 @@ int act;
2395 } else { 2395 } else {
2396 i = -1; 2396 i = -1;
2397 while (*wp++ != NULL) 2397 while (*wp++ != NULL)
2398 ; 2398 ;
2399 } 2399 }
2400 vp = lookup(t->str); 2400 vp = lookup(t->str);
2401 while (setjmp(bc.brkpt)) 2401 while (setjmp(bc.brkpt))
@@ -2497,7 +2497,7 @@ forkexec( register struct op *t, int *pin, int *pout, int act, char **wp, int *p
2497 (void) &cp; 2497 (void) &cp;
2498 (void) &resetsig; 2498 (void) &resetsig;
2499 (void) &owp; 2499 (void) &owp;
2500#endif 2500#endif
2501 2501
2502 owp = wp; 2502 owp = wp;
2503 resetsig = 0; 2503 resetsig = 0;
@@ -2532,7 +2532,7 @@ forkexec( register struct op *t, int *pin, int *pout, int act, char **wp, int *p
2532 hintr = intr; 2532 hintr = intr;
2533 hbrklist = brklist; 2533 hbrklist = brklist;
2534 hexecflg = execflg; 2534 hexecflg = execflg;
2535 2535
2536 i = vfork(); 2536 i = vfork();
2537 if (i != 0) { 2537 if (i != 0) {
2538 /* who wrote this crappy non vfork safe shit? */ 2538 /* who wrote this crappy non vfork safe shit? */
@@ -2563,7 +2563,7 @@ forkexec( register struct op *t, int *pin, int *pout, int act, char **wp, int *p
2563 (*pforked)++; 2563 (*pforked)++;
2564 brklist = 0; 2564 brklist = 0;
2565 execflg = 0; 2565 execflg = 0;
2566 } 2566 }
2567 if (owp != NULL) 2567 if (owp != NULL)
2568 while ((cp = *owp++) != NULL && assign(cp, COPYV)) 2568 while ((cp = *owp++) != NULL && assign(cp, COPYV))
2569 if (shcom == NULL) 2569 if (shcom == NULL)
@@ -2841,7 +2841,7 @@ char *c, **v, **envp;
2841#endif 2841#endif
2842 optind = 1; 2842 optind = 1;
2843 if (find_applet_by_name(name)) { 2843 if (find_applet_by_name(name)) {
2844 /* We have to exec here since we vforked. Running 2844 /* We have to exec here since we vforked. Running
2845 * run_applet_by_name() won't work and bad things 2845 * run_applet_by_name() won't work and bad things
2846 * will happen. */ 2846 * will happen. */
2847 execve("/proc/self/exe", v, envp); 2847 execve("/proc/self/exe", v, envp);
@@ -2964,8 +2964,8 @@ static int dohelp(struct op *t )
2964 for (i=0, applet = applets; i < NUM_APPLETS; applet++, i++) { 2964 for (i=0, applet = applets; i < NUM_APPLETS; applet++, i++) {
2965 if (!applet->name) 2965 if (!applet->name)
2966 continue; 2966 continue;
2967 2967
2968 col += printf("%s%s", ((col == 0) ? "\t" : " "), 2968 col += printf("%s%s", ((col == 0) ? "\t" : " "),
2969 applet->name); 2969 applet->name);
2970 if (col > 60) { 2970 if (col > 60) {
2971 printf("\n"); 2971 printf("\n");
@@ -3194,7 +3194,7 @@ register struct op *t;
3194 if (n == SIGINT) 3194 if (n == SIGINT)
3195 setsig(n, onintr); 3195 setsig(n, onintr);
3196 else 3196 else
3197 setsig(n, n == SIGQUIT ? SIG_IGN 3197 setsig(n, n == SIGQUIT ? SIG_IGN
3198 : SIG_DFL); 3198 : SIG_DFL);
3199 else 3199 else
3200 setsig(n, SIG_DFL); 3200 setsig(n, SIG_DFL);
@@ -3784,7 +3784,7 @@ int quoted;
3784 /* Avoid longjmp clobbering */ 3784 /* Avoid longjmp clobbering */
3785 (void) &cp; 3785 (void) &cp;
3786#endif 3786#endif
3787 3787
3788 for (cp = e.iop->argp->aword; *cp != '`'; cp++) 3788 for (cp = e.iop->argp->aword; *cp != '`'; cp++)
3789 if (*cp == 0) { 3789 if (*cp == 0) {
3790 err("no closing `"); 3790 err("no closing `");
@@ -3837,7 +3837,7 @@ int quoted;
3837 err("unclosed ${\n"); 3837 err("unclosed ${\n");
3838 return(0); 3838 return(0);
3839 } 3839 }
3840 if (operator) { 3840 if (operator) {
3841 src++; 3841 src++;
3842 while (*src && (*src != '}')) { 3842 while (*src && (*src != '}')) {
3843 alt_value[alt_index++] = *src++; 3843 alt_value[alt_index++] = *src++;
@@ -3875,7 +3875,7 @@ int quoted;
3875 } 3875 }
3876 } 3876 }
3877 *dest = '\0'; 3877 *dest = '\0';
3878 3878
3879 if (openpipe(pf) < 0) 3879 if (openpipe(pf) < 0)
3880 return(0); 3880 return(0);
3881 while ((i = vfork()) == -1 && errno == EAGAIN) 3881 while ((i = vfork()) == -1 && errno == EAGAIN)
@@ -3897,7 +3897,7 @@ int quoted;
3897 for (j=0; j<=_NSIG; j++) 3897 for (j=0; j<=_NSIG; j++)
3898 if (ourtrap[j] && signal(j, SIG_IGN) != SIG_IGN) 3898 if (ourtrap[j] && signal(j, SIG_IGN) != SIG_IGN)
3899 signal(j, SIG_DFL); 3899 signal(j, SIG_DFL);
3900 3900
3901 dup2(pf[1], 1); 3901 dup2(pf[1], 1);
3902 closepipe(pf); 3902 closepipe(pf);
3903 3903
@@ -4121,7 +4121,7 @@ register struct wdblock *wb;
4121 wb->w_words[wb->w_nword++] = wd; 4121 wb->w_words[wb->w_nword++] = wd;
4122 return(wb); 4122 return(wb);
4123} 4123}
4124static 4124static
4125char ** 4125char **
4126getwords(wb) 4126getwords(wb)
4127register struct wdblock *wb; 4127register struct wdblock *wb;
@@ -4557,7 +4557,7 @@ register struct ioarg *ap;
4557 c = mycommand[position]; 4557 c = mycommand[position];
4558 position++; 4558 position++;
4559 return(c); 4559 return(c);
4560 } else 4560 } else
4561#endif 4561#endif
4562 { 4562 {
4563 i = safe_read(ap->afile, &c, sizeof(c)); 4563 i = safe_read(ap->afile, &c, sizeof(c));
@@ -4858,7 +4858,7 @@ int xdoll;
4858 char c; 4858 char c;
4859 char tname[30] = ".msh_XXXXXX"; 4859 char tname[30] = ".msh_XXXXXX";
4860 jmp_buf ev; 4860 jmp_buf ev;
4861 4861
4862 tf = mkstemp(tname); 4862 tf = mkstemp(tname);
4863 if (tf < 0) 4863 if (tf < 0)
4864 return (-1); 4864 return (-1);
@@ -4917,24 +4917,24 @@ int area;
4917/* 4917/*
4918 * Copyright (c) 1987,1997, Prentice Hall 4918 * Copyright (c) 1987,1997, Prentice Hall
4919 * All rights reserved. 4919 * All rights reserved.
4920 * 4920 *
4921 * Redistribution and use of the MINIX operating system in source and 4921 * Redistribution and use of the MINIX operating system in source and
4922 * binary forms, with or without modification, are permitted provided 4922 * binary forms, with or without modification, are permitted provided
4923 * that the following conditions are met: 4923 * that the following conditions are met:
4924 * 4924 *
4925 * Redistributions of source code must retain the above copyright 4925 * Redistributions of source code must retain the above copyright
4926 * notice, this list of conditions and the following disclaimer. 4926 * notice, this list of conditions and the following disclaimer.
4927 * 4927 *
4928 * Redistributions in binary form must reproduce the above 4928 * Redistributions in binary form must reproduce the above
4929 * copyright notice, this list of conditions and the following 4929 * copyright notice, this list of conditions and the following
4930 * disclaimer in the documentation and/or other materials provided 4930 * disclaimer in the documentation and/or other materials provided
4931 * with the distribution. 4931 * with the distribution.
4932 * 4932 *
4933 * Neither the name of Prentice Hall nor the names of the software 4933 * Neither the name of Prentice Hall nor the names of the software
4934 * authors or contributors may be used to endorse or promote 4934 * authors or contributors may be used to endorse or promote
4935 * products derived from this software without specific prior 4935 * products derived from this software without specific prior
4936 * written permission. 4936 * written permission.
4937 * 4937 *
4938 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND 4938 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
4939 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 4939 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
4940 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 4940 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF