mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- execve() now finds commands in the current directory again, even if you
omit the leading "./" path name. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15129 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,3 +1,6 @@
|
||||
- execve() now finds commands in the current directory again, even if you
|
||||
omit the leading "./" path name.
|
||||
|
||||
- The execve() code that looks for the command/script file now begins by
|
||||
checking if the file name includes path separators. If it does not,
|
||||
then the search for the command begins with the resident command list;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_execve.c,v 1.11 2006-08-13 15:56:38 obarthel Exp $
|
||||
* $Id: unistd_execve.c,v 1.12 2006-08-14 14:08:06 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -242,13 +242,16 @@ free_program_info(struct program_info * pi)
|
||||
static int
|
||||
find_command(const char * path,struct program_info ** result_ptr)
|
||||
{
|
||||
struct name_translation_info nti;
|
||||
char * script_line = NULL;
|
||||
struct program_info * pi;
|
||||
APTR old_window_ptr;
|
||||
int result = -1;
|
||||
BPTR old_dir;
|
||||
BPTR old_dir = ZERO;
|
||||
BOOL found_path_separator;
|
||||
const char *p = path;
|
||||
BOOL found_volume_separator;
|
||||
const char *p;
|
||||
int error;
|
||||
char c;
|
||||
|
||||
(*result_ptr) = NULL;
|
||||
@ -266,47 +269,6 @@ find_command(const char * path,struct program_info ** result_ptr)
|
||||
|
||||
memset(pi,0,sizeof(*pi));
|
||||
|
||||
/* Check if the path name uses separator characters, which
|
||||
indicate that the command should be located along a
|
||||
relative or absolute path. */
|
||||
found_path_separator = FALSE;
|
||||
|
||||
while((c = (*p++)) != '\0')
|
||||
{
|
||||
if(c == ':' || c == '/')
|
||||
{
|
||||
found_path_separator = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* No relative or absolute path given? */
|
||||
if(!found_path_separator)
|
||||
{
|
||||
/* Try to find the command on the resident list */
|
||||
pi->resident_command = find_resident_command(path);
|
||||
if(pi->resident_command == NULL)
|
||||
{
|
||||
__set_errno(ENOENT);
|
||||
goto out;
|
||||
}
|
||||
|
||||
pi->program_name = strdup(path);
|
||||
if(pi->program_name == NULL)
|
||||
{
|
||||
__set_errno(ENOMEM);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct name_translation_info nti;
|
||||
struct MsgPort * file_system;
|
||||
struct DevProc * dvp = NULL;
|
||||
BOOL done = FALSE;
|
||||
LONG io_err;
|
||||
int error = 0;
|
||||
|
||||
error = __translate_unix_to_amiga_path_name(&path,&nti);
|
||||
if(error != 0)
|
||||
{
|
||||
@ -314,9 +276,49 @@ find_command(const char * path,struct program_info ** result_ptr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Check if the path name uses separator characters, which
|
||||
indicate that the command should be located along a
|
||||
relative or absolute path. */
|
||||
found_path_separator = found_volume_separator = FALSE;
|
||||
|
||||
p = path;
|
||||
|
||||
while((c = (*p++)) != '\0')
|
||||
{
|
||||
if(c == '/')
|
||||
found_path_separator = TRUE;
|
||||
|
||||
if(c == ':')
|
||||
found_volume_separator = TRUE;
|
||||
}
|
||||
|
||||
/* No relative or absolute path given? Try the resident command list. */
|
||||
if(!found_path_separator && !found_volume_separator)
|
||||
{
|
||||
/* Try to find the command on the resident list */
|
||||
pi->resident_command = find_resident_command(path);
|
||||
if(pi->resident_command != NULL)
|
||||
{
|
||||
pi->program_name = strdup(path);
|
||||
if(pi->program_name == NULL)
|
||||
{
|
||||
__set_errno(ENOMEM);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* No resident command found? Try the file system. */
|
||||
if(pi->resident_command == NULL)
|
||||
{
|
||||
struct MsgPort * file_system;
|
||||
struct DevProc * dvp = NULL;
|
||||
BOOL done = FALSE;
|
||||
LONG io_err;
|
||||
|
||||
/* Now for the simple stuff. Find a command or command script file
|
||||
under the path name given. Handle multi-volume assignments, such as
|
||||
referring to "C:" gracefully */
|
||||
referring to "C:", gracefully */
|
||||
file_system = GetFileSysTask();
|
||||
|
||||
do
|
||||
@ -328,12 +330,16 @@ find_command(const char * path,struct program_info ** result_ptr)
|
||||
break;
|
||||
}
|
||||
|
||||
if(found_volume_separator)
|
||||
{
|
||||
dvp = GetDeviceProc((STRPTR)path,dvp);
|
||||
if(dvp != NULL)
|
||||
{
|
||||
SetFileSysTask(dvp->dvp_Port);
|
||||
|
||||
old_dir = CurrentDir(dvp->dvp_Lock);
|
||||
}
|
||||
}
|
||||
|
||||
/* First try: let's assume that that the file is
|
||||
executable */
|
||||
@ -473,9 +479,9 @@ find_command(const char * path,struct program_info ** result_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
if(dvp != NULL)
|
||||
CurrentDir(old_dir);
|
||||
}
|
||||
}
|
||||
while(!done && error == 0 && dvp != NULL && (dvp->dvp_Flags & DVPF_ASSIGN));
|
||||
|
||||
SetFileSysTask(file_system);
|
||||
|
||||
Reference in New Issue
Block a user