[vox-tech] Bash completion mystery

Bruce Wolk bawolk at ucdavis.edu
Fri Feb 24 10:16:53 PST 2012


On 02/24/2012 07:55 AM, Wes Hardaker wrote:
>>>>>> On Thu, 23 Feb 2012 19:51:27 -0800, Bryan Richter<bryan.richter at gmail.com>  said:
>
> BR>  Functions can be discovered with 'declare -f'.
>
> The problem with todays environment is that there is real-executables,
> aliases and functions.  Aliases are pretty much lame in bash so everyone
> uses functions (which can take arguments, etc).
>
> But in the end, there are in fact 3 places to look for a definition.  So
> about a month ago I wrote this:
>
>      wh()       {
>          prog="$1"
>          if [ "`declare -F $prog`" != "" ] ; then
>              declare -f $prog
>          elif alias $prog>  /dev/null 2>&1 ; then
>              alias $prog
>          else
>              which $prog
>          fi
>      }
>
> Which if you use in replace of `which` checks all three sources and
> reports the definition or location to you.
>
>    # wh ifconfig
>    /sbin/ifconfig
>
>    # wh wh
>    wh ()
>    {
>        prog="$1"
>        ...
>

Very nice.  Where is the best place to put functions like wh?  .bashrc? 
  Or do you keep a separate file that .bashrc loads?


More information about the vox-tech mailing list