Shell error to use type to determine the file


I am new to FreeBSD.
I have a script file from the old project that was written by the other people.
In the code, it used the type command to determine if the binary file is existed or not,
d=$(type dag_extract)
if [ $? -gt 0 ]; then
    err_exit "dag_extract binary cannot be found. Did you compile it?"
echo " - $d"
when I run to this part, it returns the error message. But the dag_extract does exist in the fold.

So I run the command type on the bash shell, which returns not found as shown in the picture.

But when I put this binary file in the /usr/local/bin, the type can return some values

This is really bizarre. Can anyone help me to solve this problem?
I need to put the dag_extract under the project fold as the other scripts call this binary.

Thank you very much.
It's probably a path thing. /usr/local/bin is usually part of the search path, and that's why dag_extract is found there. Normally, the current folder (.) is not part of the path for security reasons, and you would have to use type ./dag_extract to refer to the file there.
     type [name ...]
             Interpret each name as a command and print the resolution of the
             command search.  Possible resolutions are: shell keyword, alias,
             special shell builtin, shell builtin, command, tracked alias and
             not found.  For aliases the alias expansion is printed; for
             commands and tracked aliases the complete pathname of the command
             is printed.
From sh(1).
You probably want to use test(1) instead.

if [ -e dag_extract ]; then
    echo " - $d"
   err_exit "dag_extract binary cannot be found. Did you compile it?"

There are various different flags to test(1) based on whether you just want the file to exist, need it to be readable, need it to be executable, etc.

Just be sure to give it the full path in the [ ] statement.