diff options
-rw-r--r-- | shell/ash.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c index 644ef6c9d..06df07d06 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -277,8 +277,10 @@ struct jmploc { | |||
277 | }; | 277 | }; |
278 | 278 | ||
279 | struct globals_misc { | 279 | struct globals_misc { |
280 | /* pid of main shell */ | 280 | uint8_t exitstatus; /* exit status of last command */ |
281 | int rootpid; | 281 | uint8_t back_exitstatus;/* exit status of backquoted command */ |
282 | smallint job_warning; /* user was warned about stopped jobs (can be 2, 1 or 0). */ | ||
283 | int rootpid; /* pid of main shell */ | ||
282 | /* shell level: 0 for the main shell, 1 for its children, and so on */ | 284 | /* shell level: 0 for the main shell, 1 for its children, and so on */ |
283 | int shlvl; | 285 | int shlvl; |
284 | #define rootshell (!shlvl) | 286 | #define rootshell (!shlvl) |
@@ -355,10 +357,12 @@ struct globals_misc { | |||
355 | random_t random_gen; | 357 | random_t random_gen; |
356 | #endif | 358 | #endif |
357 | pid_t backgndpid; /* pid of last background process */ | 359 | pid_t backgndpid; /* pid of last background process */ |
358 | smallint job_warning; /* user was warned about stopped jobs (can be 2, 1 or 0). */ | ||
359 | }; | 360 | }; |
360 | extern struct globals_misc *const ash_ptr_to_globals_misc; | 361 | extern struct globals_misc *const ash_ptr_to_globals_misc; |
361 | #define G_misc (*ash_ptr_to_globals_misc) | 362 | #define G_misc (*ash_ptr_to_globals_misc) |
363 | #define exitstatus (G_misc.exitstatus ) | ||
364 | #define back_exitstatus (G_misc.back_exitstatus ) | ||
365 | #define job_warning (G_misc.job_warning) | ||
362 | #define rootpid (G_misc.rootpid ) | 366 | #define rootpid (G_misc.rootpid ) |
363 | #define shlvl (G_misc.shlvl ) | 367 | #define shlvl (G_misc.shlvl ) |
364 | #define minusc (G_misc.minusc ) | 368 | #define minusc (G_misc.minusc ) |
@@ -380,7 +384,6 @@ extern struct globals_misc *const ash_ptr_to_globals_misc; | |||
380 | #define trap_ptr (G_misc.trap_ptr ) | 384 | #define trap_ptr (G_misc.trap_ptr ) |
381 | #define random_gen (G_misc.random_gen ) | 385 | #define random_gen (G_misc.random_gen ) |
382 | #define backgndpid (G_misc.backgndpid ) | 386 | #define backgndpid (G_misc.backgndpid ) |
383 | #define job_warning (G_misc.job_warning) | ||
384 | #define INIT_G_misc() do { \ | 387 | #define INIT_G_misc() do { \ |
385 | (*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \ | 388 | (*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \ |
386 | barrier(); \ | 389 | barrier(); \ |
@@ -498,6 +501,8 @@ raise_interrupt(void) | |||
498 | } | 501 | } |
499 | ex_type = EXINT; | 502 | ex_type = EXINT; |
500 | } | 503 | } |
504 | /* bash: ^C even on empty command line sets $? */ | ||
505 | exitstatus = SIGINT + 128; | ||
501 | raise_exception(ex_type); | 506 | raise_exception(ex_type); |
502 | /* NOTREACHED */ | 507 | /* NOTREACHED */ |
503 | } | 508 | } |
@@ -1217,7 +1222,6 @@ static struct parsefile *g_parsefile = &basepf; /* current input file */ | |||
1217 | static int startlinno; /* line # where last token started */ | 1222 | static int startlinno; /* line # where last token started */ |
1218 | static char *commandname; /* currently executing command */ | 1223 | static char *commandname; /* currently executing command */ |
1219 | static struct strlist *cmdenviron; /* environment for builtin command */ | 1224 | static struct strlist *cmdenviron; /* environment for builtin command */ |
1220 | static uint8_t exitstatus; /* exit status of last command */ | ||
1221 | 1225 | ||
1222 | 1226 | ||
1223 | /* ============ Message printing */ | 1227 | /* ============ Message printing */ |
@@ -5877,7 +5881,6 @@ struct backcmd { /* result of evalbackcmd */ | |||
5877 | }; | 5881 | }; |
5878 | 5882 | ||
5879 | /* These forward decls are needed to use "eval" code for backticks handling: */ | 5883 | /* These forward decls are needed to use "eval" code for backticks handling: */ |
5880 | static uint8_t back_exitstatus; /* exit status of backquoted command */ | ||
5881 | #define EV_EXIT 01 /* exit after evaluating tree */ | 5884 | #define EV_EXIT 01 /* exit after evaluating tree */ |
5882 | static int evaltree(union node *, int); | 5885 | static int evaltree(union node *, int); |
5883 | 5886 | ||