#!/bin/bash RETVAL=0 declare -x NCURSINST SCDIR GROOTDIR BASHLIST KORNLIST ECMALIST TIDYLIST command -v tput >/dev/null 2>&1&&NCURSINST=1||NCURSINST=0 SCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # I AM G(IT)ROOT! GROOTDIR="$(git rev-parse --show-toplevel)"||exit 1 BASHLIST="$GROOTDIR/aux/git-checkers/bashlist" KORNLIST="$GROOTDIR/aux/git-checkers/kornlist" POSHLIST="$GROOTDIR/aux/git-checkers/poshlist" ECMALIST="$GROOTDIR/aux/git-checkers/ecmalist" TIDYLIST="$GROOTDIR/aux/git-checkers/tidylist" MAKELIST="$GROOTDIR/aux/git-checkers/makelist" function initmimick { [ -z "$1" ]&&echo "crit_fail in initmimick(): no parameter passed" >&2&&exit 1 [ -z "$2" ]&&echo "crit_fail in initmimick(): no string passed" >&2&&exit 2 case "$1" in 0) echo -en "\\033[999D";echo -en "\\033[K" case "$NCURSINST" in 1)echo -en "[ $(tput setaf 2)$(tput bold)OK$(tput sgr0) ] $2.";; *)echo -en "[ OK ] $2.";; esac echo " $3" ;; *) echo -en "\\033[999D";echo -en "\\033[K" case "$NCURSINST" in 1)echo -en "[ $(tput setaf 1)$(tput bold)FAIL$(tput sgr0) ] $2:";; *)echo -en "[ FAIL ] $2:";; esac echo " $3" ;; esac } STAGECMD="Generating Bash code list" echo -n "[....] $STAGECMD" if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep Bourne-Again|grep -vE "tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vcP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')")" -gt 0 ];then if [ -e "$GROOTDIR/.gitignore" ];then find "$GROOTDIR" -type f -exec file '{}' \;|grep Bourne-Again|grep -vE "tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')" > "$BASHLIST" else find "$GROOTDIR" -type f -exec file '{}' \;|grep Bourne-Again|grep -vE "tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"> "$BASHLIST" fi else true>"$BASHLIST" fi CRETVAL="$?" case "$CRETVAL" in 0) initmimick 0 "$STAGECMD" "...$(wc -l "$BASHLIST"|awk '{print $1}') found";; *) initmimick 1 "$STAGECMD" "...$(wc -l "$BASHLIST"|awk '{print $1}') found";((++RETVAL));; esac STAGECMD="Generating KSH code list" echo -n "[....] $STAGECMD" if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep Korn\ shell|grep -vE "/tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vcP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')")" -gt 0 ];then if [ -e "$GROOTDIR/.gitignore" ];then find "$GROOTDIR" -type f -exec file '{}' \;|grep Korn\ shell|grep -vE "/tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')" > "$KORNLIST" else find "$GROOTDIR" -type f -exec file '{}' \;|grep Korn\ shell|grep -vE "/tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g" > "$KORNLIST" fi else true>"$KORNLIST" fi CRETVAL="$?" case "$CRETVAL" in 0) initmimick 0 "$STAGECMD" "...$(wc -l "$KORNLIST"|awk '{print $1}') found";; *) initmimick 1 "$STAGECMD" "...$(wc -l "$KORNLIST"|awk '{print $1}') found";((++RETVAL));; esac STAGECMD="Generating POSIX shell code list" echo -n "[....] $STAGECMD" if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep POSIX\ shell|grep -vE "/tmp/|aux/github-markdown|\.git/"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vcP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')")" -gt 0 ];then if [ -e "$GROOTDIR/.gitignore" ];then find "$GROOTDIR" -type f -exec file '{}' \;|grep POSIX\ shell|grep -vE "/tmp/|aux/github-markdown|\.git/"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')" > "$POSHLIST" else find "$GROOTDIR" -type f -exec file '{}' \;|grep POSIX\ shell|grep -vE "/tmp/|aux/github-markdown|\.git/"|sed "s|:.*||g;s|$GROOTDIR/||g" > "$POSHLIST" fi else true>"$POSHLIST" fi CRETVAL="$?" case "$CRETVAL" in 0) initmimick 0 "$STAGECMD" "...$(wc -l "$POSHLIST"|awk '{print $1}') found";; *) initmimick 1 "$STAGECMD" "...$(wc -l "$POSHLIST"|awk '{print $1}') found";((++RETVAL));; esac STAGECMD="Generating ECMA script list" echo -n "[....] $STAGECMD" if [ "$(find "$GROOTDIR" -type f -name "*.js"|sed "s|$GROOTDIR/||g"|grep -vcE "/tmp/")" -gt 0 ];then find "$GROOTDIR" -type f -name "*.js"|sed "s|$GROOTDIR/||g"|grep -vE "/tmp/" > "$ECMALIST" 2>/dev/null else true>"$ECMALIST" fi CRETVAL="$?" case "$CRETVAL" in 0) initmimick 0 "$STAGECMD" "...$(wc -l "$ECMALIST"|awk '{print $1}') found";; *) initmimick 1 "$STAGECMD" "...$(wc -l "$ECMALIST"|awk '{print $1}') found";((++RETVAL));; esac STAGECMD="Generating PHP and HTML code list" echo -n "[....] $STAGECMD" if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep -E 'PHP script|HTML document'|sed "s|:.*||g;s|$GROOTDIR/||g"|wc -l)" -gt 0 ];then find "$GROOTDIR" -type f -exec file '{}' \;|grep -E 'PHP script|HTML document'|sed "s|:.*||g;s|$GROOTDIR/||g" > "$TIDYLIST" 2>/dev/null else true>"$TIDYLIST" fi CRETVAL="$?" case "$CRETVAL" in 0) initmimick 0 "$STAGECMD" "...$(wc -l "$TIDYLIST"|awk '{print $1}') found";; *) initmimick 1 "$STAGECMD" "...$(wc -l "$TIDYLIST"|awk '{print $1}') found";((++RETVAL));; esac STAGECMD="Generating Makefile code list" echo -n "[....] $STAGECMD" if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep makefile\ script|sed "s|:.*||g;s|$GROOTDIR/||g"|wc -l)" -gt 0 ];then find "$GROOTDIR" -type f -exec file '{}' \;|grep makefile\ script|sed "s|:.*||g;s|$GROOTDIR/||g" > "$MAKELIST" else true>"$MAKELIST" fi CRETVAL="$?" case "$CRETVAL" in 0) initmimick 0 "$STAGECMD" "...$(wc -l "$MAKELIST"|awk '{print $1}') found";; *) initmimick 1 "$STAGECMD" "...$(wc -l "$MAKELIST"|awk '{print $1}') found";((++RETVAL));; esac exit $RETVAL