aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-09-04 15:28:03 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2011-09-04 15:28:03 +0200
commit4840ae8a06298e987374fa3cc6d7e4969fd19344 (patch)
tree53fd9b0ffe5eb4a8798aa3fd6a3c1299c7357dc0 /libbb/lineedit.c
parent7b46220d922d7c6267a8442ff8c3a6d1ab106727 (diff)
downloadbusybox-4840ae8a06298e987374fa3cc6d7e4969fd19344.tar.gz
lineedit: fix atomic replace of history file; hush: fix $HISTFILE handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 10265192e..5d139043a 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1425,7 +1425,7 @@ static void save_history(char *str)
/* write out temp file and replace hist_file atomically */
new_name = xasprintf("%s.%u.new", state->hist_file, (int) getpid());
- fd = open(state->hist_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ fd = open(new_name, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd >= 0) {
FILE *fp;
int i;
@@ -1475,7 +1475,7 @@ static void remember_in_history(char *str)
/* i <= state->max_history */
state->cur_history = i;
state->cnt_history = i;
-# if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
+# if ENABLE_FEATURE_EDITING_SAVEHISTORY
if ((state->flags & SAVE_HISTORY) && state->hist_file)
save_history(str);
# endif