On Sun, 16 Mar 2014, Doug McIlroy wrote:
GNU bash, version 4.2.39(1)-release (x86_64-redhat-linux-gnu)
interprets this shell script differently when bash input comes
from a terminal or when it conmes from a file:
source(){
echo x
}
source
In the former case it prints x; in the latter it gives a
missing-filename diagnostic, presumably from the builtin "source".
The behavior is independent of whether the environment
contains "source()".
The bash man page leads me to expect the former behavior
because commands are said to be looked up first among
shell functions, then among builtins.
The behavior seems to be peculiar to "source". If "source"
is replaced by "wait, the difference vanishes.
I get the same behaviour whether entered in a terminal or executed
in a script (bash 4.2 and 4.3).
$ source(){
echo x
}
$ source
x
$ xx.sh
x