0

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 &

or

Emacs &

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.

migrated from stackoverflow.com Jun 26 at 1:54

This question came from our site for professional and enthusiast programmers.

  • 7
    On MacOS, file names are case-insensitive by default. Perhaps that's what's causing this? – legoscia Jun 13 at 11:28
  • You've got to be kidding... Indeed, eMacs for example also works. I am still wondering about the emacs appearing in the result of find, and the other mystery about the typo not seeming to have any impact. – Antoine Jun 13 at 14:22
  • 2
    Where were you when you typed that find command? I think you actually wanted something like find /Applications/Emacs.app/Contents/MacOS/ -name emacs (note the -name argument). If there was an emacs in the current directory when you ran the find command it does indeed print out emacs at the end given your command (at least on Linux it does). – Randy Morris Jun 17 at 12:15
  • I wish I remembered exactly where I ran the command. I just tried from within /usr/bin, which contains the system's emacs, but the find command doesn't output anything. Nice try, though. – Antoine Jun 18 at 13:06
  • What exactly is your question here? I didn't want to close it as unclear because this would just bounce it back to SO, but please edit your question down to what you actually want to know (ideally by considering that you now already know that macOS doesn't care so much about upper/lowercase in filenames by default, so some of the issues in your question are already explained). – nohillside Jun 26 at 3:32
4

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .