bashlex
Python parser for bash
Decision gist · record as of 2026-08-14
Yes, if you need to parse bash syntax programmatically. bashlex is stable, well-tested, has no vulnerabilities, and solves a specific problem that standard library tools cannot. The GPLv3+ license is a blocker only for proprietary projects; open-source projects should install without hesitation. The dormant maintenance status is not a concern for a parser—the bash syntax it targets is mature and unlikely to change significantly.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 2.7 or Python 3.5+; does not support Python 3.0–3.4.
- Installation is straightforward with low friction.
- The package is dormant (last release 2023-01-18, 1304 days ago) but the repository remains active and well-maintained for its scope; it has 642 stars and no known vulnerabilities.
License · maintenance · safety
GPLv3+ (copyleft) — bashlex is licensed under GPLv3+, a copyleft license. Any derivative work or distribution must also be open-source under compatible terms; proprietary projects cannot include this package without legal review.
last release 2023-01-18 (1304 days) · last repo commit 2024-04-08 · 642 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 16,475,266 downloads/mo, #1,150 on PyPI
Alternatives
Verify before relying
pip install bashlex
import bashlex
parts = bashlex.parse('echo hello')
for ast in parts:
print(ast.dump())- Whether arithmetic expressions $((..)) support is planned or considered out of scope
- Performance characteristics on very large or deeply nested bash scripts
What it is and what it does
bashlex is a Python port of GNU bash's internal parser, transliterated from C to parse bash shell syntax into a complete AST. Unlike shlex, it understands complex bash constructs such as command substitutions, process substitutions, and nested expansions, making it suitable for tools that need to analyze or manipulate bash scripts programmatically.
The package does not execute shell code—it only parses and tokenizes. It has a single runtime dependency (enum34 for older Python versions) and installs as a pure Python wheel with low friction. The codebase is dormant but stable; it was last updated in January 2023 and has no known security vulnerabilities.
Use it for
- Build shell script analyzers or linters that need to understand bash syntax beyond simple word splitting
- Implement shell command documentation tools that parse and explain bash constructs
- Extract and analyze command structures from bash scripts for auditing or refactoring
- Tokenize bash input more accurately than shlex for tools that handle process or command substitutions
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to parse bash syntax programmatically.
bashlex is stable, well-tested, has no vulnerabilities, and solves a specific problem that standard library tools cannot. The GPLv3+ license is a blocker only for proprietary projects; open-source projects should install without hesitation. The dormant maintenance status is not a concern for a parser—the bash syntax it targets is mature and unlikely to change significantly.
Install
bashlex on PyPI
Before you install
Installation is straightforward with low friction. The package is dormant (last release 2023-01-18, 1304 days ago) but the repository remains active and well-maintained for its scope; it has 642 stars and no known vulnerabilities.
Requires Python 2.7 or Python 3.5+; does not support Python 3.0–3.4.
License in practice
bashlex is licensed under GPLv3+, a copyleft license. Any derivative work or distribution must also be open-source under compatible terms; proprietary projects cannot include this package without legal review.
Quickstart
pip install bashlex
import bashlex
parts = bashlex.parse('echo hello')
for ast in parts:
print(ast.dump())
Verify before relying
- Whether arithmetic expressions $((..)) support is planned or considered out of scope
- Performance characteristics on very large or deeply nested bash scripts
Package facts
| License | GPLv3+ copyleft |
| Python support | Supports the current Python release >=2.7, !=3.0, !=3.1, !=3.2, !=3.3, !=3.4 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packageenum34 |
| Maintenance | Dormant 1,304 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 16,475,266 / month, #1,150 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)Operating System :: OS IndependentProgramming Language :: PythonTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: System ShellsTopic :: Text Processing |
Evidence: bashlex-0.18-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “bash parser python”
- bashlexbashlex parses bash shell syntax into an abstract syntax tree (AST),…
- tree-sitter-bashProvides a tree-sitter grammar for parsing Bash shell scripts into an…
- shtabGenerates shell tab completion scripts for Python CLI applications…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also oslex · shellescape · mslex · xonsh · pipe · parameter-expansion-patched · sphinx-substitution-extensions · sqlparse · ast-comments · bashkit