Suppose I write a function in a bash script, with the name of an available binary, say, pwd:
function pwd(){
echo '/'
}
Alright, that seems a bit weird, but the question is: what will happen if further in my script I write the commands:
cd /usr
pwd
What pwd will be used? Also, how can I force the use of the other one?
Your function will get called because it hides the
pwdbuiltin.To force the command to be executed, use the
commandbuiltin:From bash manual: