summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-02 15:34:47 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-02 15:34:47 +0000
commitef36ead37061690f9a20b5f03164e99ab1b9bdd4 (patch)
tree511312d277a0b7705d0e7f0b6e69c9fd80248d02 /shell/hush.c
parentdcf4de20a1904bb31d498b6cc999a37f20b2783d (diff)
downloadbusybox-w32-ef36ead37061690f9a20b5f03164e99ab1b9bdd4.tar.gz
busybox-w32-ef36ead37061690f9a20b5f03164e99ab1b9bdd4.tar.bz2
busybox-w32-ef36ead37061690f9a20b5f03164e99ab1b9bdd4.zip
hush: fix incorrect exitcodes without job control
Diffstat (limited to '')
-rw-r--r--shell/hush.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 850b38f37..8dfe2be93 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -110,8 +110,8 @@ typedef enum {
110 * output pretty */ 110 * output pretty */
111static const struct { 111static const struct {
112 int mode; 112 int mode;
113 int default_fd; 113 signed char default_fd;
114 const char *descrip; 114 char descrip[3];
115} redir_table[] = { 115} redir_table[] = {
116 { 0, 0, "()" }, 116 { 0, 0, "()" },
117 { O_RDONLY, 0, "<" }, 117 { O_RDONLY, 0, "<" },
@@ -255,7 +255,8 @@ static const char *PS1;
255static const char *PS2; 255static const char *PS2;
256#endif 256#endif
257 257
258static struct variables shell_ver = { NULL, "HUSH_VERSION", "0.01", 1, 1 }; 258#define HUSH_VER_STR "0.02"
259static struct variables shell_ver = { NULL, "HUSH_VERSION", HUSH_VER_STR, 1, 1 };
259static struct variables *top_vars = &shell_ver; 260static struct variables *top_vars = &shell_ver;
260 261
261#define B_CHUNK 100 262#define B_CHUNK 100
@@ -296,12 +297,6 @@ struct built_in_command {
296 int (*function) (char **argv); /* function ptr */ 297 int (*function) (char **argv); /* function ptr */
297}; 298};
298 299
299/* belongs in busybox.h */
300static int max(int a, int b)
301{
302 return (a > b) ? a : b;
303}
304
305#ifdef DEBUG_SHELL 300#ifdef DEBUG_SHELL
306#define debug_printf(...) fprintf(stderr, __VA_ARGS__) 301#define debug_printf(...) fprintf(stderr, __VA_ARGS__)
307/* broken, of course, but OK for testing */ 302/* broken, of course, but OK for testing */
@@ -590,14 +585,14 @@ static void hush_exit(int exitcode)
590 sigexit(- (exitcode & 0xff)); 585 sigexit(- (exitcode & 0xff));
591} 586}
592 587
593#else /* !INTERACTIVE */ 588#else /* !JOB */
594 589
595#define set_fatal_sighandler(handler) ((void)0) 590#define set_fatal_sighandler(handler) ((void)0)
596#define set_jobctrl_sighandler(handler) ((void)0) 591#define set_jobctrl_sighandler(handler) ((void)0)
597#define set_misc_sighandler(handler) ((void)0) 592#define set_misc_sighandler(handler) ((void)0)
598#define hush_exit(e) exit(-(e)) 593#define hush_exit(e) exit(e)
599 594
600#endif /* INTERACTIVE */ 595#endif /* JOB */
601 596
602 597
603static const char *set_cwd(void) 598static const char *set_cwd(void)
@@ -957,7 +952,7 @@ static int b_check_space(o_string *o, int len)
957 if (o->length + len > o->maxlen) { 952 if (o->length + len > o->maxlen) {
958 char *old_data = o->data; 953 char *old_data = o->data;
959 /* assert(data == NULL || o->maxlen != 0); */ 954 /* assert(data == NULL || o->maxlen != 0); */
960 o->maxlen += max(2*len, B_CHUNK); 955 o->maxlen += (2*len > B_CHUNK ? 2*len : B_CHUNK);
961 o->data = realloc(o->data, 1 + o->maxlen); 956 o->data = realloc(o->data, 1 + o->maxlen);
962 if (o->data == NULL) { 957 if (o->data == NULL) {
963 free(old_data); 958 free(old_data);
@@ -3299,7 +3294,7 @@ int hush_main(int argc, char **argv)
3299 hush_exit(xfunc_error_retval); 3294 hush_exit(xfunc_error_retval);
3300 } 3295 }
3301#if !ENABLE_FEATURE_SH_EXTRA_QUIET 3296#if !ENABLE_FEATURE_SH_EXTRA_QUIET
3302 printf("\n\n%s hush - the humble shell v0.02\n", BB_BANNER); 3297 printf("\n\n%s hush - the humble shell v"HUSH_VER_STR"\n", BB_BANNER);
3303 printf("Enter 'help' for a list of built-in commands.\n\n"); 3298 printf("Enter 'help' for a list of built-in commands.\n\n");
3304#endif 3299#endif
3305 } 3300 }