Skip to content

Commit 6010d1f

Browse files
Back up original file before making changes
1 parent 0fed35d commit 6010d1f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scripts/pretty-printers/gdb/install.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import os
4+
from shutil import copyfile
45

56

67
def create_gdbinit_file():
@@ -48,6 +49,14 @@ def create_gdbinit_file():
4849

4950
lines = [ "python" ] + list(map("import {}".format, sorted(imports))) + [ "", "" ] + code_block + [ "", "" ] + lines + [ "" ]
5051

52+
backup_file = os.path.join(home_folder, "backup.gdbinit")
53+
if os.path.exists(backup_file):
54+
print("backup.gdbinit file already exists. Type 'y' if you would like to overwrite it or any other key to exit.")
55+
choice = input().lower()
56+
if choice != 'y':
57+
return
58+
print("Backing up {0}".format(gdbinit_file))
59+
copyfile(gdbinit_file, backup_file)
5160
print("Adding pretty-print commands to {0}.".format(gdbinit_file))
5261
try:
5362
with open(gdbinit_file, 'w+') as file:

0 commit comments

Comments
 (0)