Skip to main content
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.

Metadata

Release files for mslex 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mslex 1.3.0
File Size Uploaded
mslex-1.3.0.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mslex 1.3.0
File Interpreter ABI Platform
mslex-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / mslex-1.3.0.tar.gz

Download URL mslex-1.3.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
641c887d1d3db610eee2af37a8e5abda3f70b3006cdfd2d0d29dc0d1ae28a85d
BLAKE2b-256 checksum
How to use checksums
e0977022667073c99a0fe028f2e34b9bf76b49a611afd21b02527fbfd92d4cd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / mslex-1.3.0-py3-none-any.whl

Download URL mslex-1.3.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7074b347201b3466fc077c5692fbce9b5f62a63a51f537a53fbbd02eff2eea4
BLAKE2b-256 checksum
How to use checksums
64f266bd65ca0139675a0d7b18f0bada6e12b51a984e41a76dbe44761bf1b3ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page