oslex is an OS-independent wrapper for shlex and mslex. Its main purpose is to provide functions similar in functionality to shlex.quote(), shlex.split(), and shlex.join() on both Windows and POSIX-compatible platforms. It achieves this by forwarding calls to the standard library's `shlex` on POSIX systems or the `mslex` library on Windows. The current version is 0.1.3, with the last release in July 2023.
pip install oslexVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core `quote`, `split`, and `join` functionalities of `oslex`, which behave consistently across operating systems by using `shlex` on POSIX and `mslex` on Windows.
Upgrade to `oslex` version 0.1.3 or later using `pip install oslex --upgrade`.
Review both MIT and Apache 2.0 licenses to ensure compatibility with your project's licensing requirements.
Thoroughly test `oslex.quote()`, `oslex.split()`, and `oslex.join()` with representative commands on both Windows and POSIX environments to ensure desired behavior.
Install the library using pip: `pip install oslex`
Install 'mslex' specifically for Windows: `pip install mslex`
Ensure the input string to `oslex.split` is correctly quoted for Windows shell syntax. If parsing problematic input, consider passing `ucrt=True` or `ucrt=False` to `oslex.split` if you know the target runtime's parsing behavior, or add `check=False` to suppress the error if unquoted metacharacters are intentional.