Skip to content
parse bash, with javascript (UNMAINTAINED)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
scripts
tests
.gitignore
.travis.yml
LICENSE Add a not-terrible LICENSE Dec 27, 2013
README.md Update README.md 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
overrides.js
package.json
parser.js Cleaninup grammar, add for loops, add some bash builtins Mar 12, 2016

README.md

shell-parse

Parse bash scripts into AST's

Synopsis

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

(better synopsis will come after real tests)

Description

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.

Examples

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

License

MIT

You can’t perform that action at this time.