]> granicus.if.org Git - icinga2/commitdiff
Don't write empty lines to the history file
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 29 Jul 2016 11:55:07 +0000 (13:55 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 29 Jul 2016 11:55:07 +0000 (13:55 +0200)
refs #12234

lib/cli/consolecommand.cpp

index 98d120cf9a9362f913f358d43c8ad317fe2939b0..5da45da65b7be6f90fff1c71cc5df305e6da6d08 100644 (file)
@@ -271,9 +271,11 @@ incomplete:
                        if (commandOnce.IsEmpty()) {
                                add_history(cline);
 
-                               historyfp.open(historyPath.CStr(), std::fstream::out | std::fstream::app);
-                               historyfp << cline << "\n";
-                               historyfp.close();
+                               if (cline[0] != '\0') {
+                                       historyfp.open(historyPath.CStr(), std::fstream::out | std::fstream::app);
+                                       historyfp << cline << "\n";
+                                       historyfp.close();
+                               }
                        }
 
                        line = cline;