Skip to content

Commit 07c0a89

Browse files
committed
Merge branch 'fix-tmuxp-issue-239'
2 parents 197c5f4 + 6a3a024 commit 07c0a89

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

libtmux/window.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import logging
1111
import os
12+
import shlex
1213

1314
from . import exc, formats
1415
from .common import (
@@ -183,7 +184,10 @@ def show_window_options(self, option=None, g=False):
183184
*tmux_args
184185
).stdout
185186

186-
cmd = [tuple(item.split(' ')) for item in cmd]
187+
# The shlex.split function splits the args at spaces, while also
188+
# retaining quoted sub-strings.
189+
# shlex.split('this is "a test"') => ['this', 'is', 'a test']
190+
cmd = [tuple(shlex.split(item)) for item in cmd]
187191

188192
window_options = dict(cmd)
189193

@@ -225,7 +229,7 @@ def show_window_option(self, option, g=False):
225229
if not len(cmd.stdout):
226230
return None
227231

228-
option = [item.split(' ') for item in cmd.stdout][0]
232+
option = [shlex.split(item) for item in cmd.stdout][0]
229233

230234
if option[1].isdigit():
231235
option = (option[0], int(option[1]))

tests/test_window.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ def test_set_show_window_options(session):
178178
assert window.show_window_options('main-pane-height') == 40
179179
assert window.show_window_options()['main-pane-height'] == 40
180180

181+
if has_gte_version('2.3'):
182+
window.set_window_option('pane-border-format', ' #P ')
183+
assert window.show_window_options('pane-border-format') == ' #P '
184+
181185

182186
def test_empty_window_option_returns_None(session):
183187
window = session.new_window(window_name='test_window')

0 commit comments

Comments
 (0)