git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] userdiff: support Bash

From
Johannes Sixt <j6t@kdbg.org>
Date
Oct 22, 2020, 06:08 UTC
Message-ID
<0d9f9ad1-2ba7-567e-97a1-a96f0b7cd4be@kdbg.org>
In-Reply-To
<6c6b5ed2166ec2c308c53bf87c78b422fdc5084f.camel@engmark.name>
Am 22.10.20 um 01:45 schrieb Victor Engmark:
Show 10 quoted lines
> 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.

Show 8 quoted lines
> 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'
> +    }
> +}
Show 12 quoted lines
> 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!
Show 33 quoted lines
> 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
Previous: Victor EngmarkNext: Junio C Hamano
Message 8 of 9 in “userdiff: support Bash”
  1. userdiff: support BashVictor Engmark, Oct 20, 2020
  2. Junio C HamanoOct 20, 2020
  3. userdiff: support BashVictor Engmark, Oct 21, 2020
  4. Johannes SixtOct 21, 2020
  5. Junio C HamanoOct 21, 2020
  6. Victor EngmarkOct 21, 2020
  7. userdiff: support BashVictor Engmark, Oct 21, 2020
  8. Johannes SixtOct 22, 2020
  9. Junio C HamanoOct 22, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.