`emacs` and `Emacs` start the same application? I am trying to understand how the shell is interpreting emacs and Emacs, and where it finds the application.  

I can launch emacs by running

bash
emacs &amp;


or

Emacs &amp;


in the terminal, and it looks to me like it is the same application (which is not the emacs shipped with the OS, which is at /usr/bin/emacs, but another one which I have installed, almost certainly with emacsformacosx though I am not sure how to verify this information).

My PATH:

$ echo "$PATH"
/Users/antoine/.gem/ruby/2.6.0/bin:/usr/local/opt/ruby/bin:/anaconda3/condabin:/Users/antoine/.pyenv/shims:/Users/antoine/.local/bin:/Applications/Emacs.app/Contents/MacOS:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin


Running

which emacs


returns

/Applications/Emacs.app/Contents/MacOS/emacs


and

which emacs


returns

/Applications/Emacs.app/Contents/MacOS/Emacs


Now if I look into the folder /Applications/Emacs.app/Contents/MacOS/, I only see Emacs but no emacs:

$ ls -1d /Applications/Emacs.app/Contents/MacOS/[eE]*
/Applications/Emacs.app/Contents/MacOS/Emacs
/Applications/Emacs.app/Contents/MacOS/Emacs-i386-10_5
/Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_10
/Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_5
/Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_7
/Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_9


On the other hand, if I use find, I get a result emacs, but I don't understand where it comes from:

$ find /Applications/Emacs.app/Contents/MacOS/ emacs | grep emacs
/Applications/Emacs.app/Contents/MacOS//bin-x86_64-10_7/emacsclient
/Applications/Emacs.app/Contents/MacOS//bin-x86_64-10_9/emacsclient
/Applications/Emacs.app/Contents/MacOS//bin-i386-10_5/emacsclient
/Applications/Emacs.app/Contents/MacOS//bin-x86_64-10_5/emacsclient
/Applications/Emacs.app/Contents/MacOS//bin-x86_64-10_10/emacsclient
emacs


but I don't see this last emacs in the folder, so where should I be looking?

(In addition, I don't understand exactly what find does, as it returns outputs without the string "emacs" in it, so I filtered them with grep).  

One last remark.
Previously I had a typo in my PATH (which I set in my .profile): I had

/Applications/Emacs.app/Contents/MacOs


(note the lower case "s" in "MacOs" at the end) instead of

/Applications/Emacs.app/Contents/MacOS


But I did not get any error, not did it seem to make any difference to correct this type.  Namely, even with the type, which emacs happily returned /Applications/Emacs.app/Contents/MacOs/emacs (with the typo) and which Emacs just as happily returned /Applications/Emacs.app/Contents/MacOs/Emacs (again with the type).

So this suggests that emacs or Emacs are found somewhere else.
The default install of macOS uses a case-insensitive file system. This is true of both HFS+ installations of macOS 10.12 (Sierra) and earlier, as well as APFS installation of macOS 10.13 (High Sierra) and later.

The use of a case-insensitive file systems means that files and folders can be reached with any mix of case in the name. The name used to create the file/folder is used verbatim when displaying the name of the file, but when you need to access it, you can mix it up:

$ touch myTeSt
$ ls
myTeSt
$ rm mytest
$ 


I.e. the case is displayed as "myTeSt" when running ls, but you can delete the file using "mytest", "MYTEST" or any variation thereof.

Naturally, this also extends to programs that you can then start using any variation of case inside the program name.

Note that it is possible to install macOS on a case-sensitive file system, where this does not apply, however it is not the default install.