Re: [PATCH v3] userdiff: support Bash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>

-- Hannes



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux