Subject: Re: 27.0.50; Newest master can't run processes on macOS

From: Paul Eggert <[email-masked]>
Date: Mon, 5 Feb 2018 11:13:16 -0800

Does the attached patch work around the macOS bug? (I don't use macOS so 
can't easily test this.) The idea of this patch is to fix both the new 
bug with file-directory-p and the circa-2012 bug with 
file-accessible-directory-p.

The bug should probably be fixed in Gnulib so that Emacs proper is 
unaffected, but first I want to check whether this fix approach works.

diff --git a/src/fileio.c b/src/fileio.c
index be29e60fc0..b0ef3d4e91 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2811,12 +2811,15 @@ file_accessible_directory_p (Lisp_Object file)
     dir = data;
   else
     {
-      /* Just check for trailing '/' when deciding whether to append '/'.
-	 That's simpler than testing the two special cases "/" and "//",
-	 and it's a safe optimization here.  */
-      char *buf = SAFE_ALLOCA (len + 3);
+      /* Just check for trailing '/' when deciding whether append '/'
+	 before appending '.'.  That's simpler than testing the two
+	 special cases "/" and "//", and it's a safe optimization
+	 here.  After appending '.', append another '/' to work around
+	 a macOS bug (Bug#30350).  */
+      static char const appended[] = "/./";
+      char *buf = SAFE_ALLOCA (len + sizeof appended);
       memcpy (buf, data, len);
-      strcpy (buf + len, &"/."[data[len - 1] == '/']);
+      strcpy (buf + len, &appended[data[len - 1] == '/']);
       dir = buf;
     }