aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--shell/ash.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 99fbf6053..0038aa1e9 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4275,7 +4275,7 @@ signal_handler(int signo)
4275 return; 4275 return;
4276 } 4276 }
4277#if ENABLE_FEATURE_EDITING 4277#if ENABLE_FEATURE_EDITING
4278 bb_got_signal = signo; /* for read_line_input: "we got a signal" */ 4278 bb_got_signal = signo; /* for read_line_input / read builtin: "we got a signal" */
4279#endif 4279#endif
4280 gotsig[signo - 1] = 1; 4280 gotsig[signo - 1] = 1;
4281 pending_sig = signo; 4281 pending_sig = signo;
@@ -15821,6 +15821,11 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
15821 if (pending_sig == 0) 15821 if (pending_sig == 0)
15822 goto again; 15822 goto again;
15823 } 15823 }
15824
15825 if ((uintptr_t)r == 2) /* -t SEC timeout? */
15826 /* bash: "The exit status is greater than 128 if the timeout is exceeded." */
15827 /* The actual value observed with bash 5.2.15: */
15828 return 128 + SIGALRM;
15824#else /* ENABLE_PLATFORM_MINGW32 */ 15829#else /* ENABLE_PLATFORM_MINGW32 */
15825 if ((uintptr_t)r == 2) { 15830 if ((uintptr_t)r == 2) {
15826 /* Timeout, return 128 + SIGALRM */ 15831 /* Timeout, return 128 + SIGALRM */
@@ -15973,8 +15978,25 @@ exitshell(void)
15973 char *p; 15978 char *p;
15974 15979
15975#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT 15980#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
15976 save_history(line_input_state); /* may be NULL */ 15981 if (line_input_state) {
15982 const char *hp;
15983# if ENABLE_FEATURE_SH_HISTFILESIZE
15984// in bash:
15985// HISTFILESIZE controls the on-disk history file size (in lines, 0=no history):
15986// "When this variable is assigned a value, the history file is truncated, if necessary"
15987// but we do it only at exit, not on assignment:
15988 /* Use HISTFILESIZE to limit file size */
15989 hp = lookupvar("HISTFILESIZE");
15990 if (hp)
15991 line_input_state->max_history = size_from_HISTFILESIZE(hp);
15992# endif
15993 /* HISTFILE: "If unset, the command history is not saved when a shell exits." */
15994 hp = lookupvar("HISTFILE");
15995 line_input_state->hist_file = hp;
15996 save_history(line_input_state); /* no-op if hist_file is NULL or "" */
15997 }
15977#endif 15998#endif
15999
15978 savestatus = exitstatus; 16000 savestatus = exitstatus;
15979 TRACE(("pid %d, exitshell(%d)\n", getpid(), savestatus)); 16001 TRACE(("pid %d, exitshell(%d)\n", getpid(), savestatus));
15980 if (setjmp(loc.loc)) 16002 if (setjmp(loc.loc))
@@ -16478,7 +16500,12 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
16478 if (hp) 16500 if (hp)
16479 line_input_state->hist_file = xstrdup(hp); 16501 line_input_state->hist_file = xstrdup(hp);
16480# if ENABLE_FEATURE_SH_HISTFILESIZE 16502# if ENABLE_FEATURE_SH_HISTFILESIZE
16481 hp = lookupvar("HISTFILESIZE"); 16503 hp = lookupvar("HISTSIZE");
16504 /* Using HISTFILESIZE above to limit max_history would be WRONG:
16505 * users may set HISTFILESIZE=0 in their profile scripts
16506 * to prevent _saving_ of history files, but still want to have
16507 * non-zero history limit for in-memory list.
16508 */
16482 line_input_state->max_history = size_from_HISTFILESIZE(hp); 16509 line_input_state->max_history = size_from_HISTFILESIZE(hp);
16483# endif 16510# endif
16484 } 16511 }