+2013-10-31 Glenn Morris <rgm@gnu.org>
+
+ * 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. (Bug#15768)
+
2013-10-29 Stefan Monnier <monnier@iro.umontreal.ca>
* keyboard.c (command_loop_1): If command is nil, call `undefined'.
startup. */
int daemon_pipe[2];
+/* If we use --chdir, this records the original directory. */
+char *original_pwd;
+
/* Save argv and argc. */
char **initial_argv;
int initial_argc;
&& NILP (Ffile_name_absolute_p (Vinvocation_directory)))
/* Emacs was started with relative path, like ./emacs.
Make it absolute. */
- Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil);
+ {
+ Lisp_Object odir = original_pwd ? build_string (original_pwd) : Qnil;
+ Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, odir);
+ }
Vinstallation_directory = Qnil;
}
if (argmatch (argv, argc, "-chdir", "--chdir", 4, &ch_to_dir, &skip_args))
- if (chdir (ch_to_dir) == -1)
- {
- fprintf (stderr, "%s: Can't chdir to %s: %s\n",
- argv[0], ch_to_dir, strerror (errno));
- exit (1);
- }
+ {
+ original_pwd = get_current_dir_name ();
+ if (chdir (ch_to_dir) == -1)
+ {
+ fprintf (stderr, "%s: Can't chdir to %s: %s\n",
+ argv[0], ch_to_dir, strerror (errno));
+ exit (1);
+ }
+ }
dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0
|| strcmp (argv[argc - 1], "bootstrap") == 0);