[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#629247: lintian: Lacks a decent shell script parser



On Jun 4, 2011 22:19 "Niels Thykier" <niels@thykier.net> wrote:
> [...]
> Hey,
> 
> Tracker bug for stuff like #398658.
> 
> ~Niels
>  
> [...]
> 

As far as I can tell, writing a full (and correct) parser for bash
is not going to be trivial.  But we may be able improve the accuracy
of our current ad-hoc parser by adding some "Text::ParseWords" to the
mix.

A fair simple perl snippet (attached) seems to be fairly accurate in
its tokenization of private/refresh-debhelper-data.  I have noticed
two issues so far:
 * Contents of heredocs (<<EOF ... EOF) are tokenized and probably
   shouldn't be.
 * ";" are not split into a separate token if there is no space between
   it and the previous token. (e.g. "if [ ... ]; then")

~Niels


Attachment: test.pl
Description: Perl program

Attachment: refresh-debhelper-data.tok
Description: Binary data


Reply to: