Skip to content

Static Analysis

B. van Berkum edited this page Nov 24, 2018 · 1 revision

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.

bashlex

idank/bashlex (Python, used by explainshell.com) was less than satisfactory on larger routines and complex scripts

shellcheck

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.

bash-parser

another promising canidate was the NPM package bash-parser [2018-04-23] But open issues are:

Need to learn Bison. If above issues are solved and I can see how then I think other blocking issues would be minor.

Oil

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.

Interwiki for User-Scripts (About)
Repo Wiki
core/master wiki
- forks/bvb-dev wiki

Clone this wiki locally