Fix duplicate Syslinux entries
authorTomáš Virtus <nechtom@gmail.com>
Mon, 3 Feb 2020 12:31:27 +0000 (13:31 +0100)
committerTomáš Virtus <nechtom@gmail.com>
Mon, 3 Feb 2020 12:31:32 +0000 (13:31 +0100)
Documentation of open()[1] says:

  Other common values ... and 'a' for appending (which on some Unix
  systems, means that all writes append to the end of the file
  regardless of the current seek position).

On my system (Linux 5.4), writes to a file opened as 'a+' go at the end.

[1] https://docs.python.org/3/library/functions.html#open

grml2usb

index c53f58b..5a94e10 100755 (executable)
--- a/grml2usb
+++ b/grml2usb
@@ -1323,7 +1323,7 @@ def add_entry_if_not_present(filename, entry):
     @filename: name of the file
     @entry: data to write to the file
     """
     @filename: name of the file
     @entry: data to write to the file
     """
-    data = open(filename, "a+")
+    data = open(filename, "r+")
     for line in data:
         if line == entry:
             break
     for line in data:
         if line == entry:
             break