Skip to content

Instantly share code, notes, and snippets.

@NikiforovAll
Created March 12, 2020 12:33
Show Gist options
  • Select an option

  • Save NikiforovAll/a0bdbd0562d2eb1d22bf031be3a562f2 to your computer and use it in GitHub Desktop.

Select an option

Save NikiforovAll/a0bdbd0562d2eb1d22bf031be3a562f2 to your computer and use it in GitHub Desktop.
allows to search for errors in bella hierarchically
#!/bin/sh
# grep -R --include "*.bs" 'error\[.*\]' $PROJECT_PATH | cut -d' ' -f9- | sort | uniq
geterr4m() {
METHOD_NAME="$1"
PROJECT_PATH='/c/Nikiforov/dev/nuts-bella/src/Domain/components/';
# echo $METHOD_NAME $PROJECT_PATH
METHOD_PATH=$(grep -rl --include "*.bs" "re.*${METHOD_NAME}" $PROJECT_PATH)
awk -v method_name="$METHOD_NAME" '
BEGIN {
FPAT = "([^ ]+)|(\"[^\"]+\")"
MATCH_TOKEN="^procedure\\s+" method_name "\\("
}
$0 ~ MATCH_TOKEN {
do {
getline_res = getline
if(getline_res == 0) { break }
token = $0
# print token
if(match(token, /^procedure.*[a-zA-Z]+/))
{
break;
}else if (/error\[.*\]/){
print substr($1, 7, length($1)-6-1) "," substr($0, index($0, "\""), length($0))
}
else if (/^\s+call\s+[a-zA-Z]+/){
local_mehtod_name=substr($2, 0, index($2, "(")-1)
if(local_mehtod_name == method_name) {
break
}
# print local_mehtod_name
system("geterr4m " local_mehtod_name)
}
}while(1)
}
' $METHOD_PATH | sort | uniq
}
export -f geterr4m
# METHOD_NAME=$1
METHOD_NAME="CloseTaskById"
# read METHOD_NAME
echo -e $METHOD_NAME
echo "$(geterr4m $METHOD_NAME)" | sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment