26 #if !defined (_MINIX) && defined (HAVE_SYS_FILE_H) 27 # include <sys/file.h> 30 #include "posixstat.h" 32 #if defined (HAVE_UNISTD_H) 104 for (p = execignore.
ignores; p && p->
val; p++)
122 if (stat (name, &finfo) < 0)
132 #if defined (HAVE_EACCESS) 139 if (eaccess (name,
R_OK) == 0)
149 if (access (name,
R_OK) == 0)
215 return ((s &
FS_EXECABLE) && ((s & FS_DIRECTORY) == 0));
264 char *path_list, *cmd;
272 path_list = (
char *)NULL;
274 if (path_list == 0 || *path_list ==
'\0')
290 dotexe = (
char *)
xmalloc (strlen (name) + 5);
292 strcat (dotexe,
".exe");
310 int *path_index_pointer;
337 const char *pathname;
340 char *hashed_file, *
command, *path_list;
344 hashed_file = command = (
char *)NULL;
368 hashed_file = (
char *)NULL;
373 command = hashed_file;
382 else if (temp_path || path)
394 if (
STREQ (command, pathname))
398 phash_insert ((
char *)pathname, command, dot_found_in_search, 1);
401 phash_insert ((
char *)pathname, command, dot_found_in_search, 1);
404 if (flags & CMDSRCH_STDPATH)
417 int path_index, name_len;
418 char *path_list, *path_element, *match;
420 static char **match_list =
NULL;
421 static int match_list_size = 0;
422 static int match_index = 0;
434 for (i = 0; i < match_list_size; i++)
443 match_list[1] = (
char *)NULL;
444 path_list = (
char *)NULL;
448 name_len = strlen (name);
449 file_to_lose_on = (
char *)NULL;
450 dot_found_in_search = 0;
451 if (stat (
".", &dotinfo) < 0)
452 dotinfo.st_dev = dotinfo.st_ino = 0;
457 while (path_list && path_list[path_index])
461 if (path_element == 0)
471 if (match_index + 1 == match_list_size)
473 match_list_size += 10;
474 match_list =
strvec_resize (match_list, (match_list_size + 1));
477 match_list[match_index++] = match;
478 match_list[match_index] = (
char *)NULL;
479 FREE (file_to_lose_on);
480 file_to_lose_on = (
char *)NULL;
487 match = match_list[match_index];
506 return ((
char *)NULL);
522 struct stat *dotinfop;
525 char *full_path, *xpath;
531 if (dot_found_in_search == 0 && *xpath ==
'.')
532 dot_found_in_search =
same_file (
".", xpath, dotinfop, (
struct stat *)NULL);
544 return ((
char *)NULL);
548 if (flags & FS_EXISTS)
553 if ((flags &
FS_READABLE) && (status & FS_READABLE))
561 FREE (file_to_lose_on);
562 file_to_lose_on = (
char *)NULL;
576 ((flags &
FS_NODIRS) && (status & FS_DIRECTORY)) ||
577 ((flags & FS_READABLE) && (status &
FS_READABLE) == 0))
580 return ((
char *)NULL);
604 char *full_path, *path;
605 int path_index, name_len;
610 dot_found_in_search = 0;
618 if (path_list == 0 || *path_list ==
'\0')
621 file_to_lose_on = (
char *)NULL;
622 name_len = strlen (name);
623 if (stat (
".", &dotinfo) < 0)
624 dotinfo.st_dev = dotinfo.st_ino = 0;
627 while (path_list[path_index])
651 FREE (file_to_lose_on);
664 free (file_to_lose_on);
665 file_to_lose_on = (
char *)NULL;
668 return (file_to_lose_on);
void setup_ignore_patterns(struct ignorevar *ivp)
#define CHECKHASH_DEFAULT
SHELL_VAR * find_variable_tempenv(char *name) const
int check_hashed_filenames
char ** strvec_resize(char **array, int nsize)
char ** strvec_create(int n)
static char * file_to_lose_on
static char * get_next_path_element(char *path_list, int *path_index_pointer)
static int exec_name_should_ignore(char *name) const
char * find_in_path(char *name, char *path_list, int flags) const
static nls_uint32 nls_uint32 i
char * find_path_file(char *name) const
static struct ignorevar execignore
char * sh_makepath(char *path, char *dir, int flags) const
int absolute_program(char *string) const
char * phash_search(char *filename) const
int same_file(char *path1, char *path2, struct stat *stp1, struct stat *stp2) const
static char * _find_user_command_internal(char *name, int flags) const
char * savestring(const char *s)
#define FS_EXEC_PREFERRED
char * conf_standard_path()
int executable_or_directory(char *file) const
static char * find_in_path_element(char *name, char *path, int flags, int name_len, struct stat *dotinfop) const
char * find_user_command(char *name) const
void phash_insert(char *filename, char *full_path, int check_dot, int found)
struct user_info current_user
int executable_file(char *file) const
void setup_exec_ignore(char *varname)
int strmatch(char *pattern, char *string, int flags)
int file_status(char *name) const
static char *_find_user_command_internal __P((const char *, int))
static char * find_user_command_in_path(char *name, char *path_list, int flags) const
int group_member(gid_t gid)
int is_directory(char *file) const
static char * find_user_command_internal(char *name, int flags) const
int phash_remove(char *filename) const
char * user_command_matches(char *name, int flags, int state) const
char * bash_tilde_expand(char *s, int assign_p) const
static char * find_absolute_program(char *name, int flags) const
char * get_string_value(char *var_name) const
char * search_for_command(char *pathname, int flags) const
char * extract_colon_unit(char *string, int *p_index)