aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
committerEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
commitc7bda1ce659294d6e22c06e087f6f265983c7578 (patch)
tree4c6d2217f4d8306c59cf1096f8664e1cfd167213 /shell/hush.c
parent8854004b41065b3d081af7f3df13a100b0c8bfbe (diff)
downloadbusybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.bz2
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.zip
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c112
1 files changed, 56 insertions, 56 deletions
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)