Comment by pmarreck

19 days ago

I do the same thing, but I also have a command that shows me what functions or scripts might be shadowing other scripts

Care to share?

  • the sibling answer but with `-a` before command name, will display all path hits for a command.

  •   which <commandname>

    • Seemed like it was more than that, but the comment is ambiguous. I took it to mean "show me all the commands which are shadowed" not "is this command shadowed"...

  • quite simple

    type -a <commandname>

    • this. which(1) and whereis(1) are not bash, only an approximation or coincidence at best:

        $ type -a which
        which is /usr/bin/which
      

      As a bash built-in, only the type command invokes the installed bash's code path to resolve command words:

        $ type -a type
        type is a shell builtin
        type is /usr/bin/type
      
        $ help type
        type: type [-afptP] name [name ...]
            Display information about command type.
          
            For each NAME, indicate how it would be interpreted if used as a
            command name.
          
            Options:
              -a  display all locations containing an executable named NAME;
                  includes aliases, builtins, and functions, if and only if
                  the `-p' option is not also used
              -f  suppress shell function lookup
              -P  force a PATH search for each NAME, even if it is an alias,
                  builtin, or function, and returns the name of the disk file
                  that would be executed
              -p  returns either the name of the disk file that would be executed,
                  or nothing if `type -t NAME' would not return `file'
              -t  output a single word which is one of `alias', `keyword',
                  `function', `builtin', `file' or `', if NAME is an alias,
                  shell reserved word, shell function, shell builtin, disk file,
                  or not found, respectively
          
            Arguments:
              NAME    Command name to be interpreted.
          
            Exit Status:
            Returns success if all of the NAMEs are found; fails if any are not found.
      
        $ $SHELL --version
        GNU bash, version 5.3.9(1)-release