fix: also look in $XDG_CONFIG_HOME (defaults to ~/.config) for gdbinit (#3462)

pull/3457/head
Arthur 5 days ago committed by GitHub
parent 53f3fe10c1
commit 2d3e7775de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,6 +4,7 @@ import re
from asyncio import CancelledError from asyncio import CancelledError
from contextlib import contextmanager from contextlib import contextmanager
from contextlib import nullcontext from contextlib import nullcontext
from os import environ
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from typing import Coroutine from typing import Coroutine
@ -1384,7 +1385,10 @@ class GDB(pwndbg.dbg_mod.Debugger):
if disable_any: if disable_any:
return return
home_file = Path("~/.gdbinit").expanduser().resolve() config_home = environ.get("XDG_CONFIG_HOME", Path("~/.config").expanduser().resolve())
home_file = (Path(config_home) / "gdb" / "gdbinit").resolve()
if not home_file.exists():
home_file = Path("~/.gdbinit").expanduser().resolve()
local_file = Path("./.gdbinit").resolve() local_file = Path("./.gdbinit").resolve()
def load_source(file_path: str): def load_source(file_path: str):
@ -1395,7 +1399,7 @@ class GDB(pwndbg.dbg_mod.Debugger):
is_home_loaded = False is_home_loaded = False
if not disable_home and home_file.exists(): if not disable_home and home_file.exists():
load_source("~/.gdbinit") load_source(str(home_file))
is_home_loaded = True is_home_loaded = True
disable_local = not gdb.parameter("auto-load local-gdbinit") disable_local = not gdb.parameter("auto-load local-gdbinit")

Loading…
Cancel
Save