From: Kapil <jkapil...@gmail.com>

Made a minor change of adding regex for identifying functions in shell scripts.
This regex has been tested separately from git.
For testing with git, please let me know.

This is just to get familiar with whole workflow, regex for word_regex 
parameter will be added in next patch.

---
 t/t4018-diff-funcname.sh | 1 +
 t/t4034-diff-words.sh    | 1 +
 userdiff.c               | 5 +++++
 3 files changed, 7 insertions(+)

diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 22f9f88f0a..68092eaeaa 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -44,6 +44,7 @@ diffpatterns="
        python
        ruby
        tex
+       shell
        custom1
        custom2
        custom3
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 912df91226..de21f36d97 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -314,6 +314,7 @@ test_language_driver php
 test_language_driver python
 test_language_driver ruby
 test_language_driver tex
+test_language_driver shell
 
 test_expect_success 'word-diff with diff.sbe' '
        cat >expect <<-\EOF &&
diff --git a/userdiff.c b/userdiff.c
index 3a78fbf504..1743608da2 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -170,6 +170,11 @@ IPATTERN("css",
         "-?[_a-zA-Z][-_a-zA-Z0-9]*" /* identifiers */
         "|-?[0-9]+|\\#[0-9a-fA-F]+" /* numbers */
 ),
+
+PATTERNS("shell",
+       
"([A-Za-z_][A-Za-z0-9_]*)[[:space:]]*\\([[:space:]]*\\)[[:space:]]*\\{[[:space:]\\(\\)|\\[<>?`/~!:\'\"%^&*+A-Za-z0-9_$=@;#,.-]*\\}",
+       ".*"
+),
 { "default", NULL, -1, { NULL, 0 } },
 };
 #undef PATTERNS
-- 
2.14.2

Reply via email to