Simple tool based on ShellCheck's parser that can be used to find definitions of functions in shell scripts.
Make sure you have cabal installed (at least v3 recommended).
- Clone this repository.
- Run
cabal update. - Run
cabal install --installdir=<path>. deflocbinary will be present in<path>specified in the previous step.- ...
- Profit!
You can setup defloc's COPR repository
using the following commands. Make sure you already have dnf-plugins-core
installed. Otherwise, dnf will not recognise the copr command.
# dnf copr enable lzaoral/defloc
# dnf install deflocdefloc function [scripts]$ cat test.sh
#!/usr/bin/env sh
foo() {
:
}
foo() (
:
)
function foo1() {
:
}
$ defloc foo test.sh
test.sh:foo:3:1-5:2
test.sh:foo:7:1-9:2
test.sh:foo1:11:1-13:2
# You can use regular expressions as well.
$ defloc 'foo\d' test.sh
test.sh:foo1:11:1-13:2