Skip to content

Commit

Permalink
K.I.S.S
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Oct 31, 2024
1 parent 82ae86c commit a9930ea
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -3899,17 +3899,12 @@ def get_memory_alignment(in_bits: bool = False) -> int:
def clear_screen(tty: str = "") -> None:
"""Clear the screen."""
global gef
if not tty:
cmd: str = gef.config["gef.clear_screen_command"]
gdb.execute(f"shell {cmd}")
return

# Since the tty can be closed at any time, a PermissionError exception can
# occur when `clear_screen` is called. We handle this scenario properly
try:
with open(tty, "wt") as f:
f.write("\x1b[H\x1b[J")
sys.stdout.write("\x1b[H\x1b[J")
except PermissionError:
# Since the tty can be closed at any time, a PermissionError exception can
# occur when `clear_screen` is called. We handle this scenario properly
gef.ui.redirect_fd = None
gef.config["context.redirect"] = ""
return
Expand Down Expand Up @@ -9945,7 +9940,6 @@ def __init__(self) -> None:
gef.config["gef.libc_version"] = GefSetting("", str, "Specify libc version when auto-detection fails")
gef.config["gef.main_arena_offset"] = GefSetting("", str, "Offset from libc base address to main_arena symbol (int or hex). Set to empty string to disable.")
gef.config["gef.propagate_debug_exception"] = GefSetting(False, bool, "If true, when debug mode is enabled, Python exceptions will be propagated all the way.")
gef.config["gef.clear_screen_command"] = GefSetting("clear -x", str, "Command to use to clear the screen.")

self.commands : Dict[str, GenericCommand] = collections.OrderedDict()
self.functions : Dict[str, GenericFunction] = collections.OrderedDict()
Expand Down

0 comments on commit a9930ea

Please sign in to comment.