From: Johannes Sixt <j6t@kdbg.org>
To: Victor Engmark <victor@engmark.name>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH v3] userdiff: support Bash
Date: Thu, 22 Oct 2020 08:08:29 +0200 [thread overview]
Message-ID: <0d9f9ad1-2ba7-567e-97a1-a96f0b7cd4be@kdbg.org> (raw)
In-Reply-To: <6c6b5ed2166ec2c308c53bf87c78b422fdc5084f.camel@engmark.name>
Am 22.10.20 um 01:45 schrieb Victor Engmark:
> diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
> index 2d0a03715b..5e8a973449 100644
> --- a/Documentation/gitattributes.txt
> +++ b/Documentation/gitattributes.txt
> @@ -802,6 +802,9 @@ patterns are available:
>
> - `ada` suitable for source code in the Ada language.
>
> +- `bash` suitable for source code in the Bourne-Again SHell language.
> + Covers a superset of POSIX function definitions.
OK. POSIX *shell* function definitions would have been even better, but
I think I can live with this version.
> diff --git a/t/t4018/bash-bashism-style-compact b/t/t4018/bash-bashism-style-compact
> new file mode 100644
> index 0000000000..1ca3126f61
> --- /dev/null
> +++ b/t/t4018/bash-bashism-style-compact
> @@ -0,0 +1,6 @@
> +function RIGHT {
> + function InvalidSyntax{
Nicely done!
> + :
> + echo 'ChangeMe'
> + }
> +}
> diff --git a/t/t4018/bash-nested-functions b/t/t4018/bash-nested-functions
> new file mode 100644
> index 0000000000..2c9237ead4
> --- /dev/null
> +++ b/t/t4018/bash-nested-functions
> @@ -0,0 +1,6 @@
> +outer() {
> + RIGHT() {
> + :
> + echo 'ChangeMe'
> + }
> +}
That's another very good addition!
> diff --git a/userdiff.c b/userdiff.c
> index fde02f225b..eb698eaca7 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -23,6 +23,27 @@ IPATTERN("ada",
> "[a-zA-Z][a-zA-Z0-9_]*"
> "|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?"
> "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"),
> +PATTERNS("bash",
> + /* Optional leading indentation */
> + "^[ \t]*"
> + /* Start of captured text */
> + "("
> + "("
> + /* POSIX identifier with mandatory parentheses */
> + "[a-zA-Z_][a-zA-Z0-9_]*[ \t]*\\([ \t]*\\))"
> + "|"
> + /* Bashism identifier with optional parentheses */
> + "(function[ \t]+[a-zA-Z_][a-zA-Z0-9_]*(([ \t]*\\([ \t]*\\))|([ \t]+))"
> + ")"
> + /* Optional whitespace */
> + "[ \t]*"
> + /* Compound command starting with `{`, `(`, `((` or `[[` */
> + "(\\{|\\(\\(?|\\[\\[)"
> + /* End of captured text */
> + ")",
> + /* -- */
> + /* Characters not in the default $IFS value */
> + "[^ \t]+"),
> PATTERNS("dts",
> "!;\n"
> "!=\n"
>
This is very well done. Thank you!
Acked-by: Johannes Sixt <j6t@kdbg.org>
-- Hannes
next prev parent reply other threads:[~2020-10-22 6:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 7:10 [PATCH] userdiff: support Bash Victor Engmark
2020-10-20 23:39 ` Junio C Hamano
2020-10-21 3:00 ` [PATCH v2] " Victor Engmark
2020-10-21 7:07 ` Johannes Sixt
2020-10-21 18:39 ` Junio C Hamano
2020-10-21 22:48 ` Victor Engmark
2020-10-21 23:45 ` [PATCH v3] " Victor Engmark
2020-10-22 6:08 ` Johannes Sixt [this message]
2020-10-22 17:30 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0d9f9ad1-2ba7-567e-97a1-a96f0b7cd4be@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=victor@engmark.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).