Skip to content

Commit 2c98c07

Browse files
committed
Retain spaces in quoted strings in window options
Fixes tmux-python/tmuxp#239 With the below in tmux config: setw -g pane-border-format " #P " Before the fix: ('pane-border-format', '"', '#P', '"') After the fix: ('pane-border-format', ' #P ')
1 parent e66e77d commit 2c98c07

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libtmux/window.py

Lines changed: 5 additions & 1 deletion
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 TmuxMappingObject, TmuxRelationalObject
@@ -190,7 +191,10 @@ def show_window_options(self, option=None, g=False):
190191
*tmux_args
191192
).stdout
192193

193-
cmd = [tuple(item.split(' ')) for item in cmd]
194+
# The shlex.split function splits the args at spaces, while also
195+
# retaining quoted sub-strings.
196+
# shlex.split('this is "a test"') => ['this', 'is', 'a test']
197+
cmd = [tuple(shlex.split(item)) for item in cmd]
194198

195199
window_options = dict(cmd)
196200

0 commit comments

Comments
 (0)