diff --git a/CHANGES b/CHANGES index f040a346e..1ec47ec0d 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,11 @@ $ pip install --user --upgrade --pre libtmux +### Improvement + +- pane, window commands: Impove parsing of option values that return numbers + (#520) + ### Tests - pytest: Fix `usefixture` warning (#519) diff --git a/src/libtmux/pane.py b/src/libtmux/pane.py index 907b23205..c9b5b7cc2 100644 --- a/src/libtmux/pane.py +++ b/src/libtmux/pane.py @@ -113,7 +113,7 @@ def cmd(self, cmd: str, *args: t.Any, **kwargs: t.Any) -> tmux_cmd: Specifying ``('-t', 'custom-target')`` or ``('-tcustom_target')`` in ``args`` will override using the object's ``pane_id`` as target. """ - if not any(arg.startswith("-t") for arg in args): + if not any("-t" in str(x) for x in args): args = ("-t", self.pane_id, *args) return self.server.cmd(cmd, *args, **kwargs) diff --git a/src/libtmux/window.py b/src/libtmux/window.py index 8283a0903..98401f0bd 100644 --- a/src/libtmux/window.py +++ b/src/libtmux/window.py @@ -139,7 +139,7 @@ def cmd(self, cmd: str, *args: t.Any, **kwargs: t.Any) -> tmux_cmd: Specifying ``('-t', 'custom-target')`` or ``('-tcustom_target')`` in ``args`` will override using the object's ``window_id`` as target. """ - if not any(arg.startswith("-t") for arg in args): + if not any("-t" in str(x) for x in args): args = ("-t", self.window_id, *args) return self.server.cmd(cmd, *args, **kwargs) @@ -389,7 +389,10 @@ def show_window_options(self, g: t.Optional[bool] = False) -> "WindowOptionDict" window_options: "WindowOptionDict" = {} for item in output: - key, val = shlex.split(item) + try: + key, val = shlex.split(item) + except ValueError: + logger.exception(f"Error extracting option: {item}") assert isinstance(key, str) assert isinstance(val, str)