Registry / devops / bash-parser

bash-parser

JSON →
library0.5.0jsnpmunverified

bash-parser is a JavaScript library designed to parse bash source code and generate an Abstract Syntax Tree (AST). The current stable version is 0.5.0, which was last published in June 2017, indicating the project is currently abandoned. Its development aimed to provide a standard-compliant parser, initially forked from `js-shell-parse` and significantly rewritten to leverage a `jison` grammar for robust parsing. This library was intended to serve as the core parsing engine for other projects like `cash` and `nsh`, offering a programmatic way to analyze and manipulate bash scripts. Due to its abandonment, there is no ongoing release cadence, and users should be aware that no further updates, bug fixes, or security patches will be provided.

npm install bash-parser
INSTALL
IMPORT
SIG · BASH-PARSER
B
bash-parser
devopsjavascriptv0.5.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
const parse = require('bash-parser');
import { parse } from 'bash-parser';
The library primarily uses CommonJS syntax. There is no official ESM export listed or commonly used for v0.5.0.

Demonstrates how to import the `parse` function and convert simple and complex bash commands into an AST.

const parse = require('bash-parser'); try { const ast = parse('echo "Hello World"'); console.log('Parsed AST:', JSON.stringify(ast, null, 2)); const complexAst = parse('VAR=value && command $(sub_command) || { echo error; exit 1; }'); console.log('\nParsed Complex AST:', JSON.stringify(complexAst, null, 2)); } catch (error) { console.error('Parsing error:', error.message); }
Debug
Known issues
breakingVersion 0.4.0 introduced significant breaking changes by rewriting the tokenizer from scratch and changing all AST node types (issues #25, #26). Code relying on the specific structure or naming of AST nodes from prior versions will break.
fix
Review the new AST documentation (if available) and refactor code to match the updated node types and structure.
affects: >=0.4.0
breakingWith v0.4.0, 'modes' were implemented (issue #35). While intended as a feature, this could alter default parsing behavior or require explicit mode configuration, potentially breaking existing scripts that assume a particular parsing context.
fix
Consult the 'mode' documentation (if available) to understand how parsing behavior might have changed and adjust usage accordingly.
affects: >=0.4.0
gotchaThe `bash-parser` project is abandoned. The last release (v0.5.0) was published in June 2017. This means there will be no further updates, bug fixes, security patches, or community support. Using this library in new projects or in production environments carries significant risks.
fix
Consider migrating to actively maintained alternatives for parsing bash, or be prepared to fork and maintain the library yourself.
affects: >=0.5.0
gotchaVersion 0.5.0 marked a restructuring where `bash-parser` became the only package in its repository, stemming from a Lerna monorepo setup. While this release primarily involved bumping internal dependencies, users relying on specific internal package structures or indirect dependencies might encounter subtle issues.
fix
Thoroughly test existing integrations when updating to 0.5.0, particularly if your project indirectly interacted with sub-packages that might have been part of the previous monorepo structure.
affects: =0.5.0
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
bash-parser — npm install bash-parser · libregistry