Python shlex.split(r'C:\Users\foo bar') returns ['C:Usersfoo', 'bar']: POSIX mode silently removes backslashes
shlex.split defaults to POSIX shell rules, where a backslash escapes the next character, so Windows paths, regex patterns or LaTeX arguments lose every backslash without any error: shlex.split(r'C:\Users\foo bar') gives ['C:Usersfoo', 'bar']. posix=False keeps the backslashes, but then quotes are kept as part of the tokens (shlex.split('a "b c" d', posix=False) gives ['a', '"b c"', 'd']). Comments are off by default too: 'a b # c' splits into ['a', 'b', '#', 'c'] unless comments=True. Unbalanced quotes raise ValueError: No closing quotation. Fix: avoid round-tripping commands through strings, pass argument lists directly to subprocess, use forward slashes in paths, or use posix=False and strip quotes yourself when parsing Windows-style command lines. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7 (macOS).