From: Jan Djärv Date: Fri, 31 Oct 2014 15:18:36 +0000 (+0100) Subject: * emacs.c (main): Don't chdir to $HOME on Cocoa if --chdir was given. X-Git-Tag: emacs-24.4.90~290 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=08f558056d6b7aeb7337c070e98071db7477f428;p=emacs.git * emacs.c (main): Don't chdir to $HOME on Cocoa if --chdir was given. Fixes: debbugs:18846 --- diff --git a/src/ChangeLog b/src/ChangeLog index 584207802b4..c516d348d84 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-10-31 Jan Djärv + + * emacs.c (main): Don't chdir to $HOME on Cocoa if --chdir + was given (Bug#18846). + 2014-10-30 Jan Djärv * nsterm.h (ns_set_doc_edited): Declare taking no args. diff --git a/src/emacs.c b/src/emacs.c index fd93324de97..4c3857e698d 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -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 */