-
Notifications
You must be signed in to change notification settings - Fork 0
Static Analysis
2018-11-14
Objectives:
- Find prerequisite commands (possibly resolve some vars like '$ggrep' etc.)
- Trace variable usage (possibly handle compound AST words, ie. "dynamic" Id's)
- Analyze routine complexity, gather other stats.
idank/bashlex (Python, used by explainshell.com) was less than satisfactory on larger routines and complex scripts
shellcheck (Haskell) does a nice job, looks like I have not written anything it could not parse. But what libs does it use and does it have an API to the AST.
https://github.com/koalaman/shellcheck/blob/master/ShellCheck.cabal It does expose stuff but I don't know Haskell.
another promising canidate was the NPM package bash-parser [2018-04-23] But open issues are:
- Here-doc implementation https://github.com/vorpaljs/bash-parser/issues/52
- Sub-shell nesting
dirname "$(dirname "$(dirname "$1")")"
Need to learn Bison. If above issues are solved and I can see how then I think other blocking issues would be minor.
An ambitious project, that takes the success of the Unix shell at heart.
Python based. Provides an AST for shell script (and much more), that was easily extended with an initial CLI https://github.com/bvberkum/oil/tree/feature/ast-visitor-cli
Based initial project skeleton setup somewhat on that from Oil as well.
This the main documentation wiki for User-Scripts (About)