Add function regex matching to erlang code searcher
authorSiraaj Khandkar <siraaj@khandkar.net>
Wed, 3 Mar 2021 15:23:54 +0000 (10:23 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Wed, 3 Mar 2021 15:23:54 +0000 (10:23 -0500)
home/bin/erlcode-find-calls-to-module

index 8e4d9e5..a3a8685 100755 (executable)
@@ -1,12 +1,16 @@
 #! /bin/bash
 
 target_module="$1"
-shift
+target_fun_regex="$2"
+shift 2
 dirs=$@
 
 find $dirs -type f -name '*.erl' -exec grep -Hn "\<$target_module\>:" '{}' \; \
 | sed 's/%.*$//g' \
-| awk -F "${target_module}:" -v target_module="$target_module" '
+| awk \
+    -F "${target_module}:" \
+    -v target_module="$target_module" \
+    -v target_fun_regex="$target_fun_regex" '
     $1 && $2 {
         caller_module_file = $1
         sub(":.*$", "", caller_module_file)
@@ -32,7 +36,7 @@ find $dirs -type f -name '*.erl' -exec grep -Hn "\<$target_module\>:" '{}' \; \
             print caller_module_file;
             for (cf in Calls_from) {
                 split(cf, call, SUBSEP);
-                if (call[1] == caller_module_file)
+                if (call[1] == caller_module_file && call[2] ~ target_fun_regex)
                     printf "%s%s\n", indent, call[2] | "sort";
             }
             close("sort")
This page took 0.027969 seconds and 4 git commands to generate.