[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] add support for delayed history saving
From: Dennis Groenen <tj.groenen () gmail ! com>
Date: 2011-08-21 10:24:49
Message-ID: 4E50DCF1.6070205 () gmail ! com
[Download RAW message or body]
On 08/18/2011 03:12 PM, Dennis Groenen wrote:
> There is, however, one (major) blocker with my patch. For some reason,
> both the conditions "G.line_input_state->flags& SAVE_HISTORY" and
> "G.line_input_state->hist_file" are true in hush when hush is not being
> ran as an interactive shell (e.g. hush -c "echo hello"). Saving shell
> history upon shell exit then will of course cause hush to segfault. Is
> there a bug in hush causing those conditions to be true, or am I
> overlooking something (in hush_exit())? This problem does not occur in
> ash, which shares most of its history handling code with hush. Any input
> on this is highly appreciated.
> --Dennis
I've attached a patch that simply unsets the SAVE_HISTORY flag early in
hush_main(), and re-sets it at the point hush gets interactive. This
fixes the blocker quoted above.
--Dennis
["0001-hush-don-t-save-history-when-non-interactive.patch" (text/x-patch)]
From 1984162085863e3a03db0366e6c2f27bb8800ba1 Mon Sep 17 00:00:00 2001
From: Dennis Groenen <tj.groenen@gmail.com>
Date: Sun, 21 Aug 2011 12:14:05 +0200
Subject: [PATCH] hush: don't save history when non-interactive
---
shell/hush.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/shell/hush.c b/shell/hush.c
index 6c68bfe..c4ab0a0 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7834,6 +7834,7 @@ int hush_main(int argc, char **argv)
//set_local_var(xasprintf("HISTFILE=%s", ...));
}
}
+ G.line_input_state->flags &= ~SAVE_HISTORY; /* hush is non-interactive at this point */
# if ENABLE_FEATURE_SH_HISTFILESIZE
hp = get_local_var_value("HISTFILESIZE");
G.line_input_state->max_history = size_from_HISTFILESIZE(hp);
@@ -8055,6 +8056,13 @@ int hush_main(int argc, char **argv)
* standard output is a terminal
* Refer to Posix.2, the description of the 'sh' utility.
*/
+
+#if ENABLE_FEATURE_EDITING
+# if defined MAX_HISTORY && MAX_HISTORY > 0 && ENABLE_HUSH_SAVEHISTORY
+ G.line_input_state->flags |= SAVE_HISTORY;
+# endif
+#endif
+
#if ENABLE_HUSH_JOB
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
G_saved_tty_pgrp = tcgetpgrp(STDIN_FILENO);
--
1.7.6
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic