Skip to content

Commit f5b1ae1

Browse files
committed
options(fix[scope_flag]): Skip empty Session scope flag in tmux commands
why: When explicitly passing scope=OptionScope.Session, the empty string from OPTION_SCOPE_FLAG_MAP was added as an argument, causing tmux "ambiguous option" error. tmux interprets no scope flag as session scope. what: - Check if scope_flag is truthy before adding to flags (4 locations) - Fixes set_option, unset_option, _show_options_raw, _show_option_raw
1 parent 1ec0c39 commit f5b1ae1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/libtmux/options.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,9 @@ def set_option(
676676

677677
if scope is not None and not isinstance(scope, _DefaultOptionScope):
678678
assert scope in OPTION_SCOPE_FLAG_MAP
679-
flags.append(
680-
OPTION_SCOPE_FLAG_MAP[scope],
681-
)
679+
scope_flag = OPTION_SCOPE_FLAG_MAP[scope]
680+
if scope_flag: # Session scope has empty string, skip it
681+
flags.append(scope_flag)
682682

683683
cmd = self.cmd(
684684
"set-option",
@@ -764,9 +764,9 @@ def unset_option(
764764

765765
if scope is not None and not isinstance(scope, _DefaultOptionScope):
766766
assert scope in OPTION_SCOPE_FLAG_MAP
767-
flags.append(
768-
OPTION_SCOPE_FLAG_MAP[scope],
769-
)
767+
scope_flag = OPTION_SCOPE_FLAG_MAP[scope]
768+
if scope_flag: # Session scope has empty string, skip it
769+
flags.append(scope_flag)
770770

771771
cmd = self.cmd(
772772
"set-option",
@@ -830,7 +830,9 @@ def _show_options_raw(
830830

831831
if scope is not None and not isinstance(scope, _DefaultOptionScope):
832832
assert scope in OPTION_SCOPE_FLAG_MAP
833-
flags += (OPTION_SCOPE_FLAG_MAP[scope],)
833+
scope_flag = OPTION_SCOPE_FLAG_MAP[scope]
834+
if scope_flag: # Session scope has empty string, skip it
835+
flags += (scope_flag,)
834836

835837
if include_inherited is not None and include_inherited:
836838
flags += ("-A",)
@@ -1053,7 +1055,9 @@ def _show_option_raw(
10531055

10541056
if scope is not None and not isinstance(scope, _DefaultOptionScope):
10551057
assert scope in OPTION_SCOPE_FLAG_MAP
1056-
flags += (OPTION_SCOPE_FLAG_MAP[scope],)
1058+
scope_flag = OPTION_SCOPE_FLAG_MAP[scope]
1059+
if scope_flag: # Session scope has empty string, skip it
1060+
flags += (scope_flag,)
10571061

10581062
if ignore_errors is not None and ignore_errors:
10591063
flags += ("-q",)

0 commit comments

Comments
 (0)