Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell library for parsing Bash scripts?

Does anybody know of a Haskell library which can parse arbitrary Bash scripts?

A cursory search of Hackage indicates that there's a package called bash for writing scripts, but I don't see anything for parsing them.

Basically I've just had a large collection of Bash scripts dumped on me, and I'd like to do some code analysis on it. But the first stage is obviously to be able to parse this stuff.

I don't know Bash very well personally. I suppose I could sit down and wage through the volumous man-page to get the complete BNF grammar for it. (I imagine it's very complex, given the shell's long and backwards-compatible history.) I was just wondering whether somebody else has already done this work for me...

like image 916
MathematicalOrchid Avatar asked Oct 24 '12 17:10

MathematicalOrchid


1 Answers

Perhaps extend language-sh.

Language.Sh is a collection of modules for parsing and manipulating expressions in shell grammar. This is part of a larger project, shsh. Please note that the API is somewhat unstable until we reach version 1.0.

like image 93
Don Stewart Avatar answered Sep 23 '22 08:09

Don Stewart