From 19b62d4a2981026b99f18e8d5dd58a970f867ddb Mon Sep 17 00:00:00 2001 From: Norman Koch <norman.koch@tu-dresden.de> Date: Tue, 19 Oct 2021 08:00:47 +0200 Subject: [PATCH] added -c for grep color, also added trailing whitespace and todo check --- .../util/grep-forbidden-words.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/doc.zih.tu-dresden.de/util/grep-forbidden-words.sh b/doc.zih.tu-dresden.de/util/grep-forbidden-words.sh index c5f54b4c3..d3da672cf 100755 --- a/doc.zih.tu-dresden.de/util/grep-forbidden-words.sh +++ b/doc.zih.tu-dresden.de/util/grep-forbidden-words.sh @@ -18,9 +18,9 @@ i file \+system HDFS i \<taurus\> taurus\.hrsk /taurus /TAURUS i \<hrskii\> i hpc[ -]\+da\> -i attachurl -i todo <!--.*--> -s \+$ +i ATTACHURL +i \<todo\> +i [[:space:]]$ i \(alpha\|ml\|haswell\|romeo\|gpu\|smp\|julia\|hpdlf\|scs5\)-\?\(interactive\)\?[^a-z]*partition i \[\s\?\(documentation\|here\|this \(link\|page\|subsection\)\|slides\?\|manpage\)\s\?\] i work[ -]\+space" @@ -48,13 +48,15 @@ function usage () { echo " -f Search in a specific markdown file" echo " -s Silent mode" echo " -h Show help message" + echo " -c Show git matches in color" } # Options all_files=false silent=false file="" -while getopts ":ahsf:" option; do +color="" +while getopts ":ahsf:c" option; do case $option in a) all_files=true @@ -66,6 +68,9 @@ while getopts ":ahsf:" option; do s) silent=true ;; + c) + color=" --color=always " + ;; h) usage exit;; @@ -108,7 +113,7 @@ for f in $files; do grepflag=-i ;; esac - if grep -n $grepflag "$pattern" "$f" | grepExceptions "${exceptionPatternsArray[@]}" ; then + if egrep -n $grepflag $color "$pattern" "$f" | grepExceptions "${exceptionPatternsArray[@]}" ; then ((cnt=cnt+1)) fi done <<< $exceptionPatterns -- GitLab