I'm trying to jump start my Linux (Centos) knowledge and trying to understand what is "default" Shell Functions listed by declare -F. No idea what these functions is called, I just label them as "default". I googled it, but what I got is about scripting. Is there article which explain what are they for, where (defined in which file), purpose and usage. Or someone can give a short write-up? From the look of it, they look like utilities.

For example; declare -f _have

    PATH=$PATH:/usr/sbin:/sbin:/usr/local/sbin type $1 &>/dev/null

What is the type $1 do?

BTW, I created one from the shell prompt function App1 (), then { ls }, when I check using declare -f App1 found ls had became ls --color=auto.

2 Answers 2


type is a builtin command to bash, so is described in the manual. Your _have function searches your path and 3 extra directories to see if you have a program (or alias or function), and returns a true or false value.

Your "default" functions are declared in files read by the files read at startup. You might find How to find the file where a bash function is defined? helpful. They exist because someone who put Centos together thought them to be useful.


Thank icarus. I found type is a command, but as there is no ; as a separator, I think it is something else. Just tested VAR=Apple ls and VAR=Apple ; ls , the result is the same, now I know ; is not required. But now I wonder is there a difference.

Found where is start from; /etc/profile.d/bash_completion.sh, then /usr/share/bash-completion/bash_completion.
googled and found this https://github.com/scop/bash-completion Thanks!

  • 2
    Instead of thanking icarus by posting a new answer; upvote and/or accept their answer. Note that VAR=Apple ls only sets VAR for the duration of ls; it's gone afterwards. Using VAR=Apple; ls sets VAR in the current shell (but doesn't export it).
    – Jeff Schaller
    Dec 7, 2018 at 18:30
  • Thanks Jeff, but I can't upvote. I will check can I accept as answer.
    – Yew Hang
    Dec 10, 2018 at 3:22
  • Thanks Jeff, but I can't upvote (no reputation). BTW, I tried this VAR5=GG echo ${VAR5}test and the output is test, then I tried VAR5=GG ; echo ${VAR5}test and the output is as expected GGtest. Still trying to figure out, shouldn't the first one also returned GGtest?. As far as I know bash_completion.sh provide a set of utilities, but I still wonder is it important/commonly used? Will disabling it break things? It look dated in the distro, so it kind of make me curious. Anyway, I need to get my fundamental knowledge up first.
    – Yew Hang
    Dec 10, 2018 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.