Re: [PATCH 02/18] chainlint.pl: add POSIX shell lexical analyzer
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Sep 1, 2022, 12:32 UTC
- Message-ID
- <220901.86fshbjmqj.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <c1042b9bcd94b9ecb0bf73dfbd4334b9f30ba99a.1661992197.git.gitgitgadget@gmail.com>
On Thu, Sep 01 2022, Eric Sunshine via GitGitGadget wrote:
> From: Eric Sunshine <sunshine@sunshineco.com>
Just generally on this series:
> + $tag =~ s/['"\\]//g;
I think this would be a *lot* easier to read if all of these little regex decls could be split out into some "grammar" class, or other helper module/namespace. So e.g.:
my $SCRIPT_QUOTE_RX = qr/['"\\]/;
Then:
> + return $cc if $cc =~ /^(?:&&|\|\||>>|;;|<&|>&|<>|>\|)$/;
my $SCRIPT_WHATEVER_RX = qr/ ^(?: && | \|\| [...] /x;
etc., i.e. we could then make use of /x to add inline comments to these.