--- id: oslex version: "2.0.0" license: unclear license_treatment: permissive maintenance: active --- # oslex — OS-independent wrapper for shlex and mslex License: permissive · Maintenance: active · Downloads: 780.7K/mo ## What it is and what it does oslex is a thin abstraction layer that provides a single, consistent interface for shell argument handling across Windows and POSIX systems. It forwards calls to either the standard library's shlex (on POSIX) or the mslex library (on Windows), so developers can write platform-agnostic code without conditional logic. The three core functions—join(), quote(), and split()—mirror their underlying implementations but automatically select the right one based on the current OS. The package is useful when building command-line tools, subprocess wrappers, or any code that constructs or parses shell commands and needs to work correctly on both Windows and Unix-like systems. It accepts Path objects as arguments and converts them transparently, and exposes platform-specific keyword arguments (prefixed ms_ or sh_) for fine-tuning behavior when needed. It also provides _sh and _ms variants to force a specific implementation regardless of platform. Use it for: - Build cross-platform CLI tools that safely escape and join command arguments without platform-specific branching - Parse shell command strings consistently on Windows and POSIX in subprocess or shell integration code - Quote file paths and arguments safely when constructing system commands in deployment or automation scripts - Handle mixed str and Path arguments in a single join or quote call without manual conversion - Test shell-quoting logic against both Windows and POSIX rules in the same codebase ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a unified API for shell argument quoting and parsing that works identically on Windows and POSIX systems by wrapping shlex and mslex. Yes. It solves a real cross-platform pain point with minimal overhead (one dependency, low friction), active maintenance, no known vulnerabilities, and a permissive license. Install it if you build command-line tools or subprocess wrappers that must work on both Windows and POSIX systems. ## Install pip install oslex uv add oslex poetry add oslex ## Installing oslex Before you install: Low install friction with a single runtime dependency (mslex). Actively maintained with recent commits and releases spanning multiple Python versions (3.8–3.14). License in practice: Permissive MIT license; the package itself is MIT-licensed, though it depends on mslex which is Apache 2.0-licensed, so combined use carries both permissive terms. Quickstart: import oslex # Quote arguments for the current platform quoted = oslex.quote('my argument') # Join a command list cmd = oslex.join(['echo', 'hello world']) # Split a command string args = oslex.split('echo "hello world"') Verify before relying: - Whether Path object support extends to all three main functions or only specific ones - Performance characteristics when handling large argument lists or deeply nested quoting ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 780.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags cross-platform shell argument quoting, windows posix command line parsing, shlex mslex wrapper, os-independent shell escaping, platform-agnostic command splitting, cross-platform, shell-integration, subprocess [View on SkillFed](https://skillfed.io/packages/oslex) · [View on PyPI](https://pypi.org/project/oslex/)