]> git.eshelyaron.com Git - emacs.git/commitdiff
* emacs.c (main): Don't chdir to $HOME on Cocoa if --chdir was given.
authorJan Djärv <jan.h.d@swipnet.se>
Fri, 31 Oct 2014 15:18:36 +0000 (16:18 +0100)
committerJan Djärv <jan.h.d@swipnet.se>
Fri, 31 Oct 2014 15:18:36 +0000 (16:18 +0100)
Fixes: debbugs:18846
src/ChangeLog
src/emacs.c

index 584207802b40ac91a481b3aa7dc3ddc99493ce99..c516d348d843fd01166088f4507548d8f019d8d5 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-31  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * emacs.c (main): Don't chdir to $HOME on Cocoa if --chdir
+       was given (Bug#18846).
+
 2014-10-30  Jan Djärv  <jan.h.d@swipnet.se>
 
        * nsterm.h (ns_set_doc_edited): Declare taking no args.
index fd93324de97740825fd75a7ec4c6909bee4dc687..4c3857e698d08885fb2806738b166210efefe42b 100644 (file)
@@ -716,7 +716,7 @@ main (int argc, char **argv)
 #ifdef DAEMON_MUST_EXEC
   char dname_arg2[80];
 #endif
-  char *ch_to_dir;
+  char *ch_to_dir = 0;
 
   /* If we use --chdir, this records the original directory.  */
   char *original_pwd = 0;
@@ -1240,19 +1240,19 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
       /* Started from GUI? */
       /* FIXME: Do the right thing if getenv returns NULL, or if
          chdir fails.  */
-      if (! inhibit_window_system && ! isatty (0))
+      if (! inhibit_window_system && ! isatty (0) && ! ch_to_dir)
         chdir (getenv ("HOME"));
       if (skip_args < argc)
         {
           if (!strncmp (argv[skip_args], "-psn", 4))
             {
               skip_args += 1;
-              chdir (getenv ("HOME"));
+              if (! ch_to_dir) chdir (getenv ("HOME"));
             }
           else if (skip_args+1 < argc && !strncmp (argv[skip_args+1], "-psn", 4))
             {
               skip_args += 2;
-              chdir (getenv ("HOME"));
+              if (! ch_to_dir) chdir (getenv ("HOME"));
             }
         }
 #endif  /* COCOA */