skillfed

mslex

shlex for windows

mslex v1.3.0 1.1M downloads/30d#4,397 on PyPI36
Permissive license Apache Software License 2.0 DORMANT released

What it is and what it does

mslex is a Windows-specific port of Python's shlex module that correctly handles Windows command-line quoting and parsing. Unlike shlex, which follows POSIX conventions, mslex accounts for the quirks of Windows argument parsing—specifically the different behaviors between legacy msvcrt.dll (which exhibits modulo-3 periodic quoting behavior from pre-VS 2005) and modern C runtimes (UCRT from VS 2005 onward). The package provides three functions—split, quote, and join—mirroring shlex's interface.

When parsing, mslex validates that a quoted string parses identically under both legacy and modern rules, raising an error if they disagree; you can override this by explicitly setting ucrt=True or ucrt=False. This is useful for developers building command-line tools on Windows, cross-platform build systems, or tools that invoke other Windows programs and need to correctly escape arguments. The package has no runtime dependencies and is marked Production/Stable, though development is dormant.

Use it for:

  • Building cross-platform CLI tools that need to invoke Windows executables with properly escaped arguments.
  • Implementing build systems or package managers that must handle Windows command-line parsing correctly.
  • Parsing command-line arguments from Windows programs that use either legacy or modern C runtime conventions.
  • Testing or validating Windows argument quoting in tools that generate Windows batch or PowerShell commands.
  • Migrating POSIX shell scripts to Windows while preserving correct argument handling.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides Windows-compatible command-line argument parsing and quoting, handling both legacy (pre-VS 2005) and modern C runtime argument-parsing behaviors that standard shlex does not support.

Yes, if you are building Windows command-line tools or cross-platform systems that invoke Windows programs. The package solves a real, non-obvious problem (Windows quoting is genuinely different from POSIX) with no dependencies and permissive licensing. However, dormant maintenance (667 days since last release) means you should verify it handles your specific Windows versions and C runtime targets before relying on it in production.

Install

mslex on PyPI

pip

pip install mslex

uv

uv add mslex

poetry

poetry add mslex

Installing mslex

Before you install

Low install friction; pure Python wheel with no runtime dependencies. Maintenance is dormant—last release was 667 days ago and the repository shows no recent activity, though it is not archived.

License in practice

Apache Software License 2.0 is permissive; you may use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install mslex

import mslex
quoted = mslex.quote('argument with spaces')
args = mslex.split(quoted)

Requires Python 3.5 or later; designed for Windows but can be imported on other platforms.

Verify before relying

  • Whether the package handles all edge cases in modern Windows command-line parsing beyond the documented VS 2005+ and msvcrt.dll behaviors.
  • How well the package performs on non-Windows platforms when imported (whether it gracefully degrades or requires conditional logic).
  • Real-world compatibility with Windows 11 and current C runtime versions.

Package facts

License Apache Software License 2.0 (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 667 days since the last release
Last repo commit
First released
Downloads 1,080,151/month — #4,397 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mslex-1.3.0-py3-none-any.whl

Keywords: mslex

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7

Tags

windows command line parsingshell quoting windowsmsvcrt argument parsingwindows shlex alternativecommand line escaping windowsucrt argument splittingwindows shell quote
windows-cliargument-parsing

More Utilities packages