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

From: "Niels Thykier" <[email-masked]>
Date: Sun, 03 Jun 2012 19:25:29 +0200

On Jun 4, 2011 22:19 "Niels Thykier" <[email-masked]> 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