aboutsummaryrefslogtreecommitdiff
path: root/util/fbrun
diff options
context:
space:
mode:
Diffstat (limited to 'util/fbrun')
-rw-r--r--util/fbrun/FbRun.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc
index fdc8b38..321959e 100644
--- a/util/fbrun/FbRun.cc
+++ b/util/fbrun/FbRun.cc
@@ -166,14 +166,23 @@ void FbRun::run(const std::string &command) {
166 return; 166 return;
167 } 167 }
168 168
169 for (unsigned i = 0; i != m_history.size(); ++i) { 169 int n = 1024;
170 char *a = getenv("FBRUN_HISTORY_SIZE");
171 if (a)
172 n = atoi(a);
173 int j = m_history.size();
174 --n; // NOTICE: this should be "-=2", but a duplicate entry in the late
175 // (good) section would wait "too" long
176 // (we'd wait until 3 items are left and then still skip one for being a dupe)
177 // IOW: the limit is either n or n+1, depending in the history structure
178 for (unsigned int i = 0; i != m_history.size(); ++i) {
170 // don't allow duplicates into the history file 179 // don't allow duplicates into the history file
171 if (m_history[i] == command) 180 if (--j > n || m_history[i] == command)
172 continue; 181 continue;
173
174 outfile<<m_history[i]<<endl; 182 outfile<<m_history[i]<<endl;
175 } 183 }
176 outfile<<command<<endl; 184 if (++n > 0) // n was decremented for the loop
185 outfile << command << endl;
177 outfile.close(); 186 outfile.close();
178} 187}
179 188