Skip to content

Commit f43b5e7

Browse files
author
Delphix Engineering
committed
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
2 parents 534d6bc + 2a0bbe7 commit f43b5e7

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drgn/internal/cli.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,19 @@ def main() -> None:
151151
histfile = os.path.expanduser("~/.drgn_history")
152152
try:
153153
readline.read_history_file(histfile)
154-
except FileNotFoundError:
155-
pass
156-
readline.parse_and_bind("tab: complete")
157-
readline.set_history_length(1000)
158-
atexit.register(readline.write_history_file, histfile)
154+
except OSError as e:
155+
if not isinstance(e, FileNotFoundError) and not args.quiet:
156+
print('could not read history:', str(e), file=sys.stderr)
157+
def write_history_file():
158+
try:
159+
readline.write_history_file(histfile)
160+
except OSError as e:
161+
if not args.quiet:
162+
print('could not write history:', str(e), file=sys.stderr)
163+
atexit.register(write_history_file)
159164

165+
readline.set_history_length(1000)
166+
readline.parse_and_bind("tab: complete")
160167
readline.set_completer(Completer(init_globals).complete)
161168
atexit.register(lambda: readline.set_completer(None))
162169

0 commit comments

Comments
 (0)