summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-11-24 04:37:59 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-11-24 04:37:59 +0000
commit80297d5f0cbe8a3de497804dcbb1a89e6f9c1562 (patch)
treef34fce2257aff722f25347bfce7e1375d7df5db6 /shell
parent3db254c8866de390c327d759ba615693e45aff6f (diff)
downloadbusybox-w32-1_8_2.tar.gz
busybox-w32-1_8_2.tar.bz2
busybox-w32-1_8_2.zip
Apply all post-1.8.1 patches1_8_2
Diffstat (limited to 'shell')
-rw-r--r--shell/lash.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/shell/lash.c b/shell/lash.c
index ce1ce7f6a..781dfdb5a 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -157,8 +157,8 @@ static int shell_context; /* Type prompt trigger (PS1 or PS2) */
157static char *cwd; 157static char *cwd;
158static char *local_pending_command; 158static char *local_pending_command;
159static struct jobset job_list = { NULL, NULL }; 159static struct jobset job_list = { NULL, NULL };
160static int argc; 160static int global_argc;
161static char **argv; 161static char **global_argv;
162static llist_t *close_me_list; 162static llist_t *close_me_list;
163static int last_return_code; 163static int last_return_code;
164static int last_bg_pid; 164static int last_bg_pid;
@@ -810,16 +810,16 @@ static int expand_arguments(char *command)
810 var = itoa(getpid()); 810 var = itoa(getpid());
811 break; 811 break;
812 case '#': 812 case '#':
813 var = itoa(argc-1); 813 var = itoa(global_argc - 1);
814 break; 814 break;
815 case '0':case '1':case '2':case '3':case '4': 815 case '0':case '1':case '2':case '3':case '4':
816 case '5':case '6':case '7':case '8':case '9': 816 case '5':case '6':case '7':case '8':case '9':
817 { 817 {
818 int ixx = *(dst+1)-48+1; 818 int ixx = *(dst+1)-48+1;
819 if (ixx >= argc) { 819 if (ixx >= global_argc) {
820 var = '\0'; 820 var = '\0';
821 } else { 821 } else {
822 var = argv[ixx]; 822 var = global_argv[ixx];
823 } 823 }
824 } 824 }
825 break; 825 break;
@@ -1492,12 +1492,13 @@ static inline void setup_job_control(void)
1492#endif 1492#endif
1493 1493
1494int lash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1494int lash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1495int lash_main(int argc_l, char **argv_l) 1495int lash_main(int argc, char **argv)
1496{ 1496{
1497 unsigned opt; 1497 unsigned opt;
1498 FILE *input = stdin; 1498 FILE *input = stdin;
1499 argc = argc_l; 1499
1500 argv = argv_l; 1500 global_argc = argc;
1501 global_argv = argv;
1501 1502
1502#if ENABLE_FEATURE_EDITING 1503#if ENABLE_FEATURE_EDITING
1503 line_input_state = new_line_input_t(FOR_SHELL); 1504 line_input_state = new_line_input_t(FOR_SHELL);
@@ -1510,7 +1511,7 @@ int lash_main(int argc_l, char **argv_l)
1510 job_list.fg = NULL; 1511 job_list.fg = NULL;
1511 last_return_code = 1; 1512 last_return_code = 1;
1512 1513
1513 if (argv[0] && argv[0][0] == '-') { 1514 if (global_argv[0] && global_argv[0][0] == '-') {
1514 FILE *prof_input; 1515 FILE *prof_input;
1515 prof_input = fopen("/etc/profile", "r"); 1516 prof_input = fopen("/etc/profile", "r");
1516 if (prof_input) { 1517 if (prof_input) {
@@ -1522,13 +1523,13 @@ int lash_main(int argc_l, char **argv_l)
1522 } 1523 }
1523 } 1524 }
1524 1525
1525 opt = getopt32(argv_l, "+ic:", &local_pending_command); 1526 opt = getopt32(argv, "+ic:", &local_pending_command);
1526#define LASH_OPT_i (1<<0) 1527#define LASH_OPT_i (1<<0)
1527#define LASH_OPT_c (1<<1) 1528#define LASH_OPT_c (1<<1)
1528 if (opt & LASH_OPT_c) { 1529 if (opt & LASH_OPT_c) {
1529 input = NULL; 1530 input = NULL;
1530 optind++; 1531 optind++;
1531 argv += optind; 1532 global_argv += optind;
1532 } 1533 }
1533 /* A shell is interactive if the `-i' flag was given, or if all of 1534 /* A shell is interactive if the `-i' flag was given, or if all of
1534 * the following conditions are met: 1535 * the following conditions are met:
@@ -1537,7 +1538,7 @@ int lash_main(int argc_l, char **argv_l)
1537 * standard input is a terminal 1538 * standard input is a terminal
1538 * standard output is a terminal 1539 * standard output is a terminal
1539 * Refer to Posix.2, the description of the `sh' utility. */ 1540 * Refer to Posix.2, the description of the `sh' utility. */
1540 if (argv[optind] == NULL && input == stdin 1541 if (global_argv[optind] == NULL && input == stdin
1541 && isatty(STDIN_FILENO) && isatty(STDOUT_FILENO) 1542 && isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)
1542 ) { 1543 ) {
1543 opt |= LASH_OPT_i; 1544 opt |= LASH_OPT_i;
@@ -1550,9 +1551,9 @@ int lash_main(int argc_l, char **argv_l)
1550 "Enter 'help' for a list of built-in commands.\n\n", 1551 "Enter 'help' for a list of built-in commands.\n\n",
1551 bb_banner); 1552 bb_banner);
1552 } 1553 }
1553 } else if (!local_pending_command && argv[optind]) { 1554 } else if (!local_pending_command && global_argv[optind]) {
1554 //printf( "optind=%d argv[optind]='%s'\n", optind, argv[optind]); 1555 //printf( "optind=%d argv[optind]='%s'\n", optind, argv[optind]);
1555 input = xfopen(argv[optind], "r"); 1556 input = xfopen(global_argv[optind], "r");
1556 /* be lazy, never mark this closed */ 1557 /* be lazy, never mark this closed */
1557 llist_add_to(&close_me_list, (void *)(long)fileno(input)); 1558 llist_add_to(&close_me_list, (void *)(long)fileno(input));
1558 } 1559 }