#include <signal.h>
#include <errno.h>
-#include "config.h"
+#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include "systty.h"
#include "syssignal.h"
+#include "process.h"
#ifndef O_RDWR
#define O_RDWR 2
names discarded. */
Lisp_Object Vinvocation_name;
+/* The directory name from which Emacs was invoked. */
+Lisp_Object Vinvocation_directory;
+
/* Hook run by `kill-emacs' before it does really anything. */
Lisp_Object Vkill_emacs_hook;
register int i;
Vinvocation_name = Ffile_name_nondirectory (build_string (argv[0]));
+ Vinvocation_directory = Ffile_name_directory (build_string (argv[0]));
+ /* If we got no directory in argv[0], search PATH to find where
+ Emacs actually came from. */
+ if (NILP (Vinvocation_directory))
+ {
+ Lisp_Object found;
+ int yes = openp (Vexec_path, Vinvocation_name,
+ EXEC_SUFFIXES, &found, 1);
+ if (yes == 1)
+ Vinvocation_directory = Ffile_name_directory (found);
+ }
Vcommand_line_args = Qnil;
return Fcopy_sequence (Vinvocation_name);
}
+DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
+ 0, 0, 0,
+ "Return the directory name in which the Emacs executable was located")
+ ()
+{
+ return Fcopy_sequence (Vinvocation_directory);
+}
+
\f
#ifdef VMS
#ifdef LINK_CRTL_SHARE
{}
__do_global_dtors ()
{}
+/* Linux has a bug in its library; avoid an error. */
+#ifndef LINUX
char * __CTOR_LIST__[2] = { (char *) (-1), 0 };
+#endif
char * __DTOR_LIST__[2] = { (char *) (-1), 0 };
__main ()
{}
until calling init_callproc. */
set_process_environment ();
+ init_buffer (); /* Init default directory of main buffer */
+
+ init_callproc (); /* Must precede init_cmdargs and init_sys_modes. */
+ init_cmdargs (argc, argv, skip_args); /* Must precede init_lread. */
init_lread ();
- init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */
- init_buffer (); /* Init default directory of main buffer */
if (!noninteractive)
{
#ifdef VMS
init_display (); /* Determine terminal type. init_sys_modes uses results */
}
init_keyboard (); /* This too must precede init_sys_modes */
- init_callproc (); /* And this too. */
#ifdef VMS
init_vmsproc (); /* And this too. */
#endif /* VMS */
syms_of_print ();
syms_of_eval ();
syms_of_fns ();
-#ifdef LISP_FLOAT_TYPE
syms_of_floatfns ();
-#endif
syms_of_abbrev ();
syms_of_buffer ();
defsubr (&Skill_emacs);
defsubr (&Sinvocation_name);
+ defsubr (&Sinvocation_directory);
DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
"Args passed by shell to Emacs, as a list of strings.");
staticpro (&Vinvocation_name);
Vinvocation_name = Qnil;
+ staticpro (&Vinvocation_directory);
+ Vinvocation_directory = Qnil;
}