I have heard it said, multiple times, that in Bash source is merely an alias for .. Even in the Bash man page. However, I've noticed, while digging into this question that they are not identical when called via find. Here is a reproducible example:
I've created a file called test.sh
uberhumus@pc:~/tmp$ cat ./test.sh
#!/bin/bash
echo "Kazabooboo"
uberhumus@pc:~/tmp$ find ~/tmp -type f -iname "test.sh" -exec . {} \;
find: ‘.’: Permission denied
uberhumus@pc:~/tmp$ ind ~/tmp -type f -iname "test.sh" -exec source {} \;
find: ‘source’: No such file or directory
My question is what causes the difference, and are there any other differences that aren't discussed?
In
bash,sourceand.are the same, as the man page says.What you are doing here is testing if
findtreatssourceand.the same way. It does not.findunderstands that.is the current directory. You cannotexecthe current directory; permission is denied.if
findneeds to executesource, there must be an external programsourceavailable. There is none in yourPATH, so you getNo such file or directoryThe fact that they are different for
finddoes not imply that there is a difference forbash.