getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.6k stars 445 forks source link

Shlex does not parse Windows paths correctly #3649

Closed JesperDramsch closed 1 year ago

JesperDramsch commented 1 year ago

Environment

Python Version: 3.10.8

Nikola Version: v8.2.3

Operating System: Windows

Description:

The Gzip task used shlex to lexically parse input commands from GZIP_COMMAND.

The example is "pigz -k {filename}", however this causes an "error in pigz" because pigz -k outputlatestindex.html does not exist.

This is a know problem of shlex:

https://stackoverflow.com/questions/33560364/python-windows-parsing-command-lines-with-shlex

Proposed solution:

Change command to

    if command:
        if sys.platform == 'win32':
            subprocess.check_call(command.format(filename=in_path))
        else:
            subprocess.check_call(shlex.split(command.format(filename=in_path)))

from the StackOverflow, which would be the cleanest option.