diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-07-28 15:14:45 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-07-28 15:14:45 +0000 |
commit | 501c88b245fdc63f3f2a044fd7704bb468db3904 (patch) | |
tree | 3fff440532d8d380ae7e4f2933bc7163360f8279 /shell/cmdedit.c | |
parent | 6a99aaf0208151b7f5e5058efaa409496e2b7c4b (diff) | |
download | busybox-w32-501c88b245fdc63f3f2a044fd7704bb468db3904.tar.gz busybox-w32-501c88b245fdc63f3f2a044fd7704bb468db3904.tar.bz2 busybox-w32-501c88b245fdc63f3f2a044fd7704bb468db3904.zip |
More sh updates (with related changes to everything else). Switched
to using getopt and cleaned up the resulting mess. if-then-else-fi
is now basically working (given a bunch of constraints).
-Erik
Diffstat (limited to 'shell/cmdedit.c')
-rw-r--r-- | shell/cmdedit.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 0ce64beeb..042064f1e 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -84,6 +84,7 @@ static int cmdedit_termw = 80; /* actual terminal width */ | |||
84 | static int cmdedit_scroll = 27; /* width of EOL scrolling region */ | 84 | static int cmdedit_scroll = 27; /* width of EOL scrolling region */ |
85 | static int history_counter = 0; /* Number of commands in history list */ | 85 | static int history_counter = 0; /* Number of commands in history list */ |
86 | static int reset_term = 0; /* Set to true if the terminal needs to be reset upon exit */ | 86 | static int reset_term = 0; /* Set to true if the terminal needs to be reset upon exit */ |
87 | static int exithandler_set = 0; /* Set to true when atexit() has been called */ | ||
87 | 88 | ||
88 | struct history { | 89 | struct history { |
89 | char *s; | 90 | char *s; |
@@ -709,10 +710,32 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
709 | 710 | ||
710 | extern void cmdedit_init(void) | 711 | extern void cmdedit_init(void) |
711 | { | 712 | { |
712 | atexit(cmdedit_reset_term); | 713 | if(exithandler_set == 0) { |
714 | atexit(cmdedit_reset_term); /* be sure to do this only once */ | ||
715 | exithandler_set = 1; | ||
716 | } | ||
713 | signal(SIGKILL, clean_up_and_die); | 717 | signal(SIGKILL, clean_up_and_die); |
714 | signal(SIGINT, clean_up_and_die); | 718 | signal(SIGINT, clean_up_and_die); |
715 | signal(SIGQUIT, clean_up_and_die); | 719 | signal(SIGQUIT, clean_up_and_die); |
716 | signal(SIGTERM, clean_up_and_die); | 720 | signal(SIGTERM, clean_up_and_die); |
717 | } | 721 | } |
722 | |||
723 | /* | ||
724 | ** Undo the effects of cmdedit_init() as good as we can: | ||
725 | ** I am not aware of a way to revoke an atexit() handler, | ||
726 | ** but, fortunately, our particular handler can be made | ||
727 | ** a no-op by setting reset_term = 0. | ||
728 | */ | ||
729 | extern void cmdedit_terminate(void) | ||
730 | { | ||
731 | cmdedit_reset_term(); | ||
732 | reset_term = 0; | ||
733 | signal(SIGKILL, SIG_DFL); | ||
734 | signal(SIGINT, SIG_DFL); | ||
735 | signal(SIGQUIT, SIG_DFL); | ||
736 | signal(SIGTERM, SIG_DFL); | ||
737 | } | ||
738 | |||
739 | |||
740 | |||
718 | #endif /* BB_FEATURE_SH_COMMAND_EDITING */ | 741 | #endif /* BB_FEATURE_SH_COMMAND_EDITING */ |