mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 23:14:55 +02:00
Make shlex_split always return a token
Matches behavior of split() so is therefore more intuitive
This commit is contained in:
@@ -1215,14 +1215,22 @@ def key_val_matcher(items: Iterable[tuple[str, str]], key_pat: 're.Pattern[str]'
|
||||
|
||||
def shlex_split(text: str, allow_ansi_quoted_strings: bool = False) -> Iterator[str]:
|
||||
s = Shlex(text, allow_ansi_quoted_strings)
|
||||
yielded = False
|
||||
while (q := s.next_word())[0] > -1:
|
||||
yield q[1]
|
||||
yielded = True
|
||||
if not yielded:
|
||||
yield ''
|
||||
|
||||
|
||||
def shlex_split_with_positions(text: str, allow_ansi_quoted_strings: bool = False) -> Iterator[tuple[int, str]]:
|
||||
s = Shlex(text, allow_ansi_quoted_strings)
|
||||
yielded = False
|
||||
while (q := s.next_word())[0] > -1:
|
||||
yield q
|
||||
yielded = True
|
||||
if not yielded:
|
||||
yield 0, ''
|
||||
|
||||
|
||||
def timed_debug_print(*a: Any, sep: str = ' ', end: str = '\n') -> None:
|
||||
|
||||
Reference in New Issue
Block a user