Skip to content
parse bash, with javascript (UNMAINTAINED)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Add a not-terrible LICENSE Dec 27, 2013 Update Oct 1, 2018
build.js Print nicer errors for shellcheck tests Mar 12, 2016
grammar.pegjs Cleaninup grammar, add for loops, add some bash builtins Mar 12, 2016
parser.js Cleaninup grammar, add for loops, add some bash builtins Mar 12, 2016


Parse bash scripts into AST's


var parse = require('shell-parse')
parse('echo $PATH') //=> an ugly AST object

(better synopsis will come after real tests)


This thing parses strings containing bash scripts into an AST that you might execute using an interpreter or something. The AST structure is still in flux, so you probably don't want to build on this just yet!

If you want to help, there's a whole bunch of failing test fixtures (borrowed from the lovely shellcheck project). You can start with reading the grammar. The grammar defines how text will be matched, while the corresponding rule callbacks in overrides.js defines the way those matches will be processed into AST nodes. Be sure to read the comments as there's a tiny bit of magic going on.

If you get stuck trying to fix a test case, email me. GitHub issue notifications almost never get my attention.


See the tests for all the things that can be parsed.



You can’t perform that action at this time.