{"id":12878,"library":"bash-parser","title":"Bash Source Code Parser","description":"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.","status":"abandoned","version":"0.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/vorpaljs/bash-parser","tags":["javascript"],"install":[{"cmd":"npm install bash-parser","lang":"bash","label":"npm"},{"cmd":"yarn add bash-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add bash-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library primarily uses CommonJS syntax. There is no official ESM export listed or commonly used for v0.5.0.","wrong":"import { parse } from 'bash-parser';","symbol":"parse","correct":"const parse = require('bash-parser');"}],"quickstart":{"code":"const parse = require('bash-parser');\n\ntry {\n  const ast = parse('echo \"Hello World\"');\n  console.log('Parsed AST:', JSON.stringify(ast, null, 2));\n\n  const complexAst = parse('VAR=value && command $(sub_command) || { echo error; exit 1; }');\n  console.log('\\nParsed Complex AST:', JSON.stringify(complexAst, null, 2));\n} catch (error) {\n  console.error('Parsing error:', error.message);\n}","lang":"javascript","description":"Demonstrates how to import the `parse` function and convert simple and complex bash commands into an AST."},"warnings":[{"fix":"Review the new AST documentation (if available) and refactor code to match the updated node types and structure.","message":"Version 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.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Consult the 'mode' documentation (if available) to understand how parsing behavior might have changed and adjust usage accordingly.","message":"With 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.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Consider migrating to actively maintained alternatives for parsing bash, or be prepared to fork and maintain the library yourself.","message":"The `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.","severity":"gotcha","affected_versions":">=0.5.0"},{"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.","message":"Version 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.","severity":"gotcha","affected_versions":"=0.5.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null}