Re: [PATCH v2 0/1] [PATCH v2 0/1] [GSOC 2025] [Newbie] userdiff: add built-in pattern for shell scripts
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Feb 18, 2025, 17:30 UTC
- Message-ID
- <CAPig+cStFE7r2-Kd-js_VHjuF5LGp+0Kniez61i1-Lus=gyVHQ@mail.gmail.com>
- In-Reply-To
- <20250218153537.16320-1-dhar61595@gmail.com>
On Tue, Feb 18, 2025 at 10:36 AM Moumita <dhar61595@gmail.com> wrote:
> The modifications that I made were -
> "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*\\([ \t]*\\)[ \t]*" - so that is allows foo() and foo ( ).
> "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*\\([ \t]*\\)[ \t]*(\\{|\\(|\\[\\[)" - so that it recognises {, (, or [[ as function bodiesRegarding this last point, for completeness, I had meant to respond to j6t's review of your patch by saying that, according to POSIX, a function body can be any compound command, which means the body does not need to be encased in braces. For instance, this works:
$ foo() echo nothing
$ foo
nothing
$That said, I doubt that this usage is common, thus is probably not worth worrying about.