const char *);
\f
/* Return the current buffer's working directory, or the home
- directory if it's unreachable, as a string suitable for a system call.
- Signal an error if the result would not be an accessible directory. */
+ directory if it's unreachable. If ENCODE is true, return as a string
+ suitable for a system call; otherwise, return a string in its
+ internal representation. Signal an error if the result would not be
+ an accessible directory. */
Lisp_Object
-encode_current_directory (void)
+get_current_directory (bool encode)
{
Lisp_Object curdir = BVAR (current_buffer, directory);
Lisp_Object dir = Funhandled_file_name_directory (curdir);
dir = build_string ("~");
dir = expand_and_dir_to_file (dir);
- dir = ENCODE_FILE (remove_slash_colon (dir));
+ Lisp_Object encoded_dir = ENCODE_FILE (remove_slash_colon (dir));
- if (! file_accessible_directory_p (dir))
+ if (! file_accessible_directory_p (encoded_dir))
report_file_error ("Setting current directory", curdir);
- return dir;
+ return encode ? encoded_dir : dir;
}
/* If P is reapable, record it as a deleted process and kill it.
The remaining arguments are optional.
The program's input comes from file INFILE (nil means `null-device').
-If you want to make the input come from an Emacs buffer, use
-`call-process-region' instead.
+If INFILE is a relative path, it will be looked for relative to the
+directory where the process is run (see below). If you want to make the
+input come from an Emacs buffer, use `call-process-region' instead.
Third argument DESTINATION specifies how to handle program's output.
If DESTINATION is a buffer, or t that stands for the current buffer,
if (nargs >= 2 && ! NILP (args[1]))
{
- infile = Fexpand_file_name (args[1], BVAR (current_buffer, directory));
+ /* Expand infile relative to the current buffer's current
+ directory, or its unhandled equivalent ("~"). */
+ infile = Fexpand_file_name (args[1], get_current_directory (false));
CHECK_STRING (infile);
}
else
buffer's current directory, or its unhandled equivalent. We
can't just have the child check for an error when it does the
chdir, since it's in a vfork. */
- current_dir = encode_current_directory ();
+ current_dir = get_current_directory (true);
if (STRINGP (error_file))
{