Ensure 'call-process' interprets INFILE as a local path
* src/callproc.c (get_current_directory): Rename from 'encode_current_directory' and add boolean ENCODE flag. (Fcall_process): Interpret INFILE relative to the working directory from which PROGRAM is run, not 'default-directory'. (call_process): Use 'get_current_directory'. * src/process.c (Fmake_process): Use 'get_current_directory'. * src/process.h (get_current_directory): Rename decl from 'encode_current_directory'. * src/sysdep.c (sys_subshell): Use 'get_current_directory' (bug#49283).
This commit is contained in:
parent
46d4ddd176
commit
2f2afa0b31
4 changed files with 18 additions and 13 deletions
|
@ -116,11 +116,13 @@ static CHILD_SETUP_TYPE child_setup (int, int, int, char **, char **,
|
|||
const char *);
|
||||
|
||||
/* 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);
|
||||
|
@ -131,12 +133,12 @@ encode_current_directory (void)
|
|||
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.
|
||||
|
@ -225,8 +227,9 @@ DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0,
|
|||
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,
|
||||
|
@ -270,7 +273,9 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
|
|||
|
||||
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
|
||||
|
@ -439,7 +444,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
|
|||
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))
|
||||
{
|
||||
|
|
|
@ -1755,7 +1755,7 @@ usage: (make-process &rest ARGS) */)
|
|||
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);
|
||||
|
||||
name = Fplist_get (contact, QCname);
|
||||
CHECK_STRING (name);
|
||||
|
|
|
@ -264,7 +264,7 @@ enum
|
|||
|
||||
/* Defined in callproc.c. */
|
||||
|
||||
extern Lisp_Object encode_current_directory (void);
|
||||
extern Lisp_Object get_current_directory (bool);
|
||||
extern void record_kill_process (struct Lisp_Process *, Lisp_Object);
|
||||
|
||||
/* Defined in sysdep.c. */
|
||||
|
|
|
@ -657,7 +657,7 @@ sys_subshell (void)
|
|||
#endif
|
||||
pid_t pid;
|
||||
struct save_signal saved_handlers[5];
|
||||
char *str = SSDATA (encode_current_directory ());
|
||||
char *str = SSDATA (get_current_directory (true));
|
||||
|
||||
#ifdef DOS_NT
|
||||
pid = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue