diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-04-23 15:28:28 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-04-23 15:28:28 +0000 |
commit | ed424dbf1d3d4f0448b9bfdc6b6128d4c90514ee (patch) | |
tree | 5b613c1439ae5bb391a398d5f5a0f011d4da9215 | |
parent | d8862928c25be9b00f6755cf445773cd1e4cc22a (diff) | |
download | busybox-w32-ed424dbf1d3d4f0448b9bfdc6b6128d4c90514ee.tar.gz busybox-w32-ed424dbf1d3d4f0448b9bfdc6b6128d4c90514ee.tar.bz2 busybox-w32-ed424dbf1d3d4f0448b9bfdc6b6128d4c90514ee.zip |
Some patches from Gennady Feldman. Fixed a glob problem such that
'ls *.h Config.h' works. Fixed a silly typo with fg/bg process control.
Made cmdedit exit sanely when it cannot read input.
-rw-r--r-- | cmdedit.c | 4 | ||||
-rw-r--r-- | lash.c | 10 | ||||
-rw-r--r-- | sh.c | 10 | ||||
-rw-r--r-- | shell/cmdedit.c | 4 | ||||
-rw-r--r-- | shell/lash.c | 10 |
5 files changed, 21 insertions, 17 deletions
@@ -1211,7 +1211,8 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1211 | fflush(stdout); /* buffered out to fast */ | 1211 | fflush(stdout); /* buffered out to fast */ |
1212 | 1212 | ||
1213 | if (read(inputFd, &c, 1) < 1) | 1213 | if (read(inputFd, &c, 1) < 1) |
1214 | return; | 1214 | /* if we can't read input then exit */ |
1215 | goto prepare_to_die; | ||
1215 | 1216 | ||
1216 | switch (c) { | 1217 | switch (c) { |
1217 | case '\n': | 1218 | case '\n': |
@@ -1243,6 +1244,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1243 | /* Control-d -- Delete one character, or exit | 1244 | /* Control-d -- Delete one character, or exit |
1244 | * if the len=0 and no chars to delete */ | 1245 | * if the len=0 and no chars to delete */ |
1245 | if (len == 0) { | 1246 | if (len == 0) { |
1247 | prepare_to_die: | ||
1246 | printf("exit"); | 1248 | printf("exit"); |
1247 | clean_up_and_die(0); | 1249 | clean_up_and_die(0); |
1248 | } else { | 1250 | } else { |
@@ -1019,6 +1019,8 @@ static int expand_arguments(char *command) | |||
1019 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { | 1019 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { |
1020 | if (*tmpcmd == '\0') | 1020 | if (*tmpcmd == '\0') |
1021 | break; | 1021 | break; |
1022 | /* we need to trim() the result for glob! */ | ||
1023 | trim(tmpcmd); | ||
1022 | retval = glob(tmpcmd, flags, NULL, &expand_result); | 1024 | retval = glob(tmpcmd, flags, NULL, &expand_result); |
1023 | free(tmpcmd); /* Free mem allocated by strsep_space */ | 1025 | free(tmpcmd); /* Free mem allocated by strsep_space */ |
1024 | if (retval == GLOB_NOSPACE) { | 1026 | if (retval == GLOB_NOSPACE) { |
@@ -1041,10 +1043,8 @@ static int expand_arguments(char *command) | |||
1041 | error_msg(out_of_space); | 1043 | error_msg(out_of_space); |
1042 | return FALSE; | 1044 | return FALSE; |
1043 | } | 1045 | } |
1044 | if (i>0) { | 1046 | strcat(command+total_length, " "); |
1045 | strcat(command+total_length, " "); | 1047 | total_length+=1; |
1046 | total_length+=1; | ||
1047 | } | ||
1048 | strcat(command+total_length, expand_result.gl_pathv[i]); | 1048 | strcat(command+total_length, expand_result.gl_pathv[i]); |
1049 | total_length+=length; | 1049 | total_length+=length; |
1050 | } | 1050 | } |
@@ -1803,7 +1803,7 @@ static int busy_loop(FILE * input) | |||
1803 | if (!job_list.fg) { | 1803 | if (!job_list.fg) { |
1804 | /* move the shell to the foreground */ | 1804 | /* move the shell to the foreground */ |
1805 | /* suppress messages when run from /linuxrc mag@sysgo.de */ | 1805 | /* suppress messages when run from /linuxrc mag@sysgo.de */ |
1806 | if (tcsetpgrp(0, getpid()) && errno != ENOTTY) | 1806 | if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY) |
1807 | perror_msg("tcsetpgrp"); | 1807 | perror_msg("tcsetpgrp"); |
1808 | } | 1808 | } |
1809 | } | 1809 | } |
@@ -1019,6 +1019,8 @@ static int expand_arguments(char *command) | |||
1019 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { | 1019 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { |
1020 | if (*tmpcmd == '\0') | 1020 | if (*tmpcmd == '\0') |
1021 | break; | 1021 | break; |
1022 | /* we need to trim() the result for glob! */ | ||
1023 | trim(tmpcmd); | ||
1022 | retval = glob(tmpcmd, flags, NULL, &expand_result); | 1024 | retval = glob(tmpcmd, flags, NULL, &expand_result); |
1023 | free(tmpcmd); /* Free mem allocated by strsep_space */ | 1025 | free(tmpcmd); /* Free mem allocated by strsep_space */ |
1024 | if (retval == GLOB_NOSPACE) { | 1026 | if (retval == GLOB_NOSPACE) { |
@@ -1041,10 +1043,8 @@ static int expand_arguments(char *command) | |||
1041 | error_msg(out_of_space); | 1043 | error_msg(out_of_space); |
1042 | return FALSE; | 1044 | return FALSE; |
1043 | } | 1045 | } |
1044 | if (i>0) { | 1046 | strcat(command+total_length, " "); |
1045 | strcat(command+total_length, " "); | 1047 | total_length+=1; |
1046 | total_length+=1; | ||
1047 | } | ||
1048 | strcat(command+total_length, expand_result.gl_pathv[i]); | 1048 | strcat(command+total_length, expand_result.gl_pathv[i]); |
1049 | total_length+=length; | 1049 | total_length+=length; |
1050 | } | 1050 | } |
@@ -1803,7 +1803,7 @@ static int busy_loop(FILE * input) | |||
1803 | if (!job_list.fg) { | 1803 | if (!job_list.fg) { |
1804 | /* move the shell to the foreground */ | 1804 | /* move the shell to the foreground */ |
1805 | /* suppress messages when run from /linuxrc mag@sysgo.de */ | 1805 | /* suppress messages when run from /linuxrc mag@sysgo.de */ |
1806 | if (tcsetpgrp(0, getpid()) && errno != ENOTTY) | 1806 | if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY) |
1807 | perror_msg("tcsetpgrp"); | 1807 | perror_msg("tcsetpgrp"); |
1808 | } | 1808 | } |
1809 | } | 1809 | } |
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index eef1a88c8..ce5450032 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -1211,7 +1211,8 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1211 | fflush(stdout); /* buffered out to fast */ | 1211 | fflush(stdout); /* buffered out to fast */ |
1212 | 1212 | ||
1213 | if (read(inputFd, &c, 1) < 1) | 1213 | if (read(inputFd, &c, 1) < 1) |
1214 | return; | 1214 | /* if we can't read input then exit */ |
1215 | goto prepare_to_die; | ||
1215 | 1216 | ||
1216 | switch (c) { | 1217 | switch (c) { |
1217 | case '\n': | 1218 | case '\n': |
@@ -1243,6 +1244,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1243 | /* Control-d -- Delete one character, or exit | 1244 | /* Control-d -- Delete one character, or exit |
1244 | * if the len=0 and no chars to delete */ | 1245 | * if the len=0 and no chars to delete */ |
1245 | if (len == 0) { | 1246 | if (len == 0) { |
1247 | prepare_to_die: | ||
1246 | printf("exit"); | 1248 | printf("exit"); |
1247 | clean_up_and_die(0); | 1249 | clean_up_and_die(0); |
1248 | } else { | 1250 | } else { |
diff --git a/shell/lash.c b/shell/lash.c index 243ba8139..892237b08 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -1019,6 +1019,8 @@ static int expand_arguments(char *command) | |||
1019 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { | 1019 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { |
1020 | if (*tmpcmd == '\0') | 1020 | if (*tmpcmd == '\0') |
1021 | break; | 1021 | break; |
1022 | /* we need to trim() the result for glob! */ | ||
1023 | trim(tmpcmd); | ||
1022 | retval = glob(tmpcmd, flags, NULL, &expand_result); | 1024 | retval = glob(tmpcmd, flags, NULL, &expand_result); |
1023 | free(tmpcmd); /* Free mem allocated by strsep_space */ | 1025 | free(tmpcmd); /* Free mem allocated by strsep_space */ |
1024 | if (retval == GLOB_NOSPACE) { | 1026 | if (retval == GLOB_NOSPACE) { |
@@ -1041,10 +1043,8 @@ static int expand_arguments(char *command) | |||
1041 | error_msg(out_of_space); | 1043 | error_msg(out_of_space); |
1042 | return FALSE; | 1044 | return FALSE; |
1043 | } | 1045 | } |
1044 | if (i>0) { | 1046 | strcat(command+total_length, " "); |
1045 | strcat(command+total_length, " "); | 1047 | total_length+=1; |
1046 | total_length+=1; | ||
1047 | } | ||
1048 | strcat(command+total_length, expand_result.gl_pathv[i]); | 1048 | strcat(command+total_length, expand_result.gl_pathv[i]); |
1049 | total_length+=length; | 1049 | total_length+=length; |
1050 | } | 1050 | } |
@@ -1803,7 +1803,7 @@ static int busy_loop(FILE * input) | |||
1803 | if (!job_list.fg) { | 1803 | if (!job_list.fg) { |
1804 | /* move the shell to the foreground */ | 1804 | /* move the shell to the foreground */ |
1805 | /* suppress messages when run from /linuxrc mag@sysgo.de */ | 1805 | /* suppress messages when run from /linuxrc mag@sysgo.de */ |
1806 | if (tcsetpgrp(0, getpid()) && errno != ENOTTY) | 1806 | if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY) |
1807 | perror_msg("tcsetpgrp"); | 1807 | perror_msg("tcsetpgrp"); |
1808 | } | 1808 | } |
1809 | } | 1809 | } |