Skip to main content

shlex for windows

Project description

https://img.shields.io/pypi/v/mslex.svg https://img.shields.io/travis/com/smoofra/mslex.svg Documentation Status

shlex for windows

Features

This is the missing shlex package for windows shell quoting. It provides three functions – split, quote, and join – just like shlex.

Windows Quoting

Since time immemorial, windows quoting behavior has been strange. Prior to (I think) Visual Studio 2005, it exhibited the extremely strange modulo 3 periodic behavior which is emulated here in split_msvcrt(). Programs compiled with the C runtime from Visual Studio 2005 and later exhibit the somewhat less strange behavior emulated in split_ucrt().

Microsoft still ships a dll called msvcrt.dll as part of Windows, for compatibility reasons. And even though they have been very clear in their documentation that nobody should ever link against this dll, people still do, either for compatibility reasons of their own, or because it is universally available on any version of windows you might care about without needing to run an installer. And msvcrt.dll preserves the extremely strange argument parsing behavior from prior to VS 2005.

You can can download the latest version of msys2 today and build an executable linking msvcrt.dll on Windows 11, and it will parse arguments like Windows 95.

mslex will produce quoted strings that will be parsed correctly by either modern C runtimes or by msvcrt.dll. When parsing, mslex parses it both ways and raises an error if they disagree. This can be overridden by passing ucrt=True or ucrt=False to split.

See also:

Automatic selection between mslex and shlex

If you want to automatically use mslex on Windows, and shlex otherwise, check out the oslex package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mslex-1.3.0.tar.gz (11.6 kB view hashes)

Uploaded Source

Built Distribution

mslex-1.3.0-py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page