Skip to content

grncdr/js-shell-parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f5f65af · Dec 21, 2018

History

64 Commits
Mar 11, 2016
Mar 12, 2016
Dec 28, 2013
Mar 11, 2016
Dec 27, 2013
Oct 1, 2018
Mar 12, 2016
Mar 12, 2016
Mar 12, 2016
Mar 12, 2016
Mar 12, 2016

Repository files navigation

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