oslex2
oslex2 is an OS-independent wrapper for Python's shlex (POSIX) and mslex (Windows) modules.
Like
os.pathabstracts overposixpathandntpath,oslex2abstracts overshlexandmslexfor shell-quoting and splitting.
Features
- Unified API for shell quoting, splitting, and joining on all platforms
- Automatically uses
shlexon POSIX andmslexon Windows - Drop-in replacement for
shlexin cross-platform code
Installation
pip install oslex2
Usage
import oslex2
# Safely quote a string for the shell
cmd = oslex2.quote('foo; rm -rf /')
# Split a shell command into arguments
args = oslex2.split('python -m pip install "oslex2>=1.0.0"')
# Join arguments into a shell command
command = oslex2.join(["python", "-m", "pip", "install", "oslex2>=1.0.0"])
API
oslex2.quote(s: str, **kwargs) -> str: Shell-escape a string for safe use as a single token.oslex2.split(s: str, **kwargs) -> List[str]: Split a shell command string into arguments.oslex2.join(args: List[str]) -> str: Join arguments into a shell-escaped command string.
Note: All functions accept **kwargs and pass them through to the underlying shlex or mslex implementation. This allows you to use platform-specific options (such as posix, punctuation_chars, etc.) as needed.
Platform Detection
- On Windows, uses
mslexfor Windows shell syntax. - On all other platforms, uses the standard library
shlex.
License
- MIT License (this library)
mslexis Apache 2.0
Links
Metadata
Release files for oslex2 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oslex2-1.0.0.tar.gz | 16.4 kB | With provenance | Details for oslex2-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oslex2-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for oslex2-1.0.0-py3-none-any.whl |
Total release size: 19.9 kB
Release files / oslex2-1.0.0.tar.gz
| Download URL | oslex2-1.0.0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f85ade0d6594e77b4388105c45de7880c7ec57ef018a6ff80088cd392bcd1876
|
|
BLAKE2b-256 checksum How to use checksums |
c65dfaf8eff4efea3e55ce6cc597ab777af4c9d5a5b3f21dba3224729a7e8bc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2025.
Transparency logRelease files / oslex2-1.0.0-py3-none-any.whl
| Download URL | oslex2-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2db57a36da65b83b482ff140f7637a02249fc324ba23189b1ed64bd7b928151
|
|
BLAKE2b-256 checksum How to use checksums |
ae33671e0118ee490cd4be9e9674d94aa483dccb66ba37b8a440ca1951b4e2ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2025.
Transparency logSecurity for oslex2 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for oslex2-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.