aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlenn Morris2013-10-31 00:18:42 -0700
committerGlenn Morris2013-10-31 00:18:42 -0700
commit8fd0741784e0cbaa3fd5b9c0c69bf3397818586b (patch)
tree584221edb58705ff7f3613f71424bf656a702388 /src
parentbed64093f764c17050c71f2323f30c9a745769d9 (diff)
downloademacs-8fd0741784e0cbaa3fd5b9c0c69bf3397818586b.tar.gz
emacs-8fd0741784e0cbaa3fd5b9c0c69bf3397818586b.zip
Fix setting of invocation-directory with --chdir and relative argv[0]
* src/emacs.c (original_pwd): New char. (main): If using --chdir, store original_pwd. (init_cmdargs): When setting Vinvocation_directory based on a relative argv[0], use original_pwd if set. Fixes: debbugs:15768
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/emacs.c23
2 files changed, 23 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7dab8c0d64e..64d7ea5c181 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12013-10-31 Glenn Morris <rgm@gnu.org>
2
3 * emacs.c (original_pwd): New char.
4 (main): If using --chdir, store original_pwd.
5 (init_cmdargs): When setting Vinvocation_directory based on a
6 relative argv[0], use original_pwd if set. (Bug#15768)
7
12013-10-29 Stefan Monnier <monnier@iro.umontreal.ca> 82013-10-29 Stefan Monnier <monnier@iro.umontreal.ca>
2 9
3 * keyboard.c (command_loop_1): If command is nil, call `undefined'. 10 * keyboard.c (command_loop_1): If command is nil, call `undefined'.
diff --git a/src/emacs.c b/src/emacs.c
index b5d281da317..e2b47bddb32 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -202,6 +202,9 @@ static char *daemon_name;
202 startup. */ 202 startup. */
203int daemon_pipe[2]; 203int daemon_pipe[2];
204 204
205/* If we use --chdir, this records the original directory. */
206char *original_pwd;
207
205/* Save argv and argc. */ 208/* Save argv and argc. */
206char **initial_argv; 209char **initial_argv;
207int initial_argc; 210int initial_argc;
@@ -426,7 +429,10 @@ init_cmdargs (int argc, char **argv, int skip_args)
426 && NILP (Ffile_name_absolute_p (Vinvocation_directory))) 429 && NILP (Ffile_name_absolute_p (Vinvocation_directory)))
427 /* Emacs was started with relative path, like ./emacs. 430 /* Emacs was started with relative path, like ./emacs.
428 Make it absolute. */ 431 Make it absolute. */
429 Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil); 432 {
433 Lisp_Object odir = original_pwd ? build_string (original_pwd) : Qnil;
434 Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, odir);
435 }
430 436
431 Vinstallation_directory = Qnil; 437 Vinstallation_directory = Qnil;
432 438
@@ -786,12 +792,15 @@ main (int argc, char **argv)
786 } 792 }
787 793
788 if (argmatch (argv, argc, "-chdir", "--chdir", 4, &ch_to_dir, &skip_args)) 794 if (argmatch (argv, argc, "-chdir", "--chdir", 4, &ch_to_dir, &skip_args))
789 if (chdir (ch_to_dir) == -1) 795 {
790 { 796 original_pwd = get_current_dir_name ();
791 fprintf (stderr, "%s: Can't chdir to %s: %s\n", 797 if (chdir (ch_to_dir) == -1)
792 argv[0], ch_to_dir, strerror (errno)); 798 {
793 exit (1); 799 fprintf (stderr, "%s: Can't chdir to %s: %s\n",
794 } 800 argv[0], ch_to_dir, strerror (errno));
801 exit (1);
802 }
803 }
795 804
796 dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0 805 dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0
797 || strcmp (argv[argc - 1], "bootstrap") == 0); 806 || strcmp (argv[argc - 1], "bootstrap") == 0);