about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2021-05-24 20:37:39 +0200
committerSören Tempel <soeren+git@soeren-tempel.net>2021-05-24 20:37:39 +0200
commit9ab521202855bcf4ea82ae37d89a9f1eae06f43d (patch)
treea5eecfa17422dbe22cf5223179189e00214574e1
parent8b3bb2d4c9bb3e9cfccf327194cb8209daadf384 (diff)
history: Use .rstrip() for removing trailing newlines
-rw-r--r--saneterm/history.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/saneterm/history.py b/saneterm/history.py
index 12882e1..1226446 100644
--- a/saneterm/history.py
+++ b/saneterm/history.py
@@ -34,13 +34,10 @@ class History():
         self.__con.close()
 
     def add_entry(self, fd, entry):
-        exe = self.__get_exec(fd)
-
-        # Strip trailing newline (if any).
+        entry = entry.rstrip('\n')
         if len(entry) == 0:
             return
-        elif entry[-1] == '\n':
-            entry = entry[0:-1]
+        exe = self.__get_exec(fd)
 
         # Insert new entry into table and make sure the **total** amount
         # of entries in the entire table does not exceed self.histsize.