From 9d7dc3ecede8de44f32778fd72e6ef809d1274e0 Mon Sep 17 00:00:00 2001 From: Alexandre De Dommelin Date: Sun, 12 Mar 2017 15:49:46 -0700 Subject: empty-history # Description: Don't create an empty history file when History=0 # Author: Gbp-Pq: Name 50-empty-history.patch --- src/history.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/history.cc b/src/history.cc index 33d946c..63601aa 100644 --- a/src/history.cc +++ b/src/history.cc @@ -65,17 +65,19 @@ HistoryFile::sync_the_file() if (!configuration.get_int("History", HIST_MAX_SIZE)) HIST_MAX_SIZE = 20; - ofstream f(filename, ios::out); + if (HIST_MAX_SIZE) { + ofstream f(filename, ios::out); - int start = 0; - if (history.size() > (size_t)HIST_MAX_SIZE) - start = history.size() - HIST_MAX_SIZE; + int start = 0; + if (history.size() > (size_t)HIST_MAX_SIZE) + start = history.size() - HIST_MAX_SIZE; - for (size_t i = start; i < history.size(); i++) - if (history[i].length() != 0) - f << history[i] << endl; + for (size_t i = start; i < history.size(); i++) + if (history[i].length() != 0) + f << history[i] << endl; - f.flush(); + f.flush(); + } } void -- cgit v1.2.3