Changes to support GNO-style PATH in type and source commands, and in tab completion.

This commit is contained in:
Stephen Heumann 2014-12-26 21:49:55 -06:00
parent 4c37e05f0c
commit 6dfc5eadb3
2 changed files with 16 additions and 2 deletions

View File

@ -853,6 +853,12 @@ enum {
FIND_FILE_ONLY = 2
};
#ifndef __GNO__
# define PATH_SEP ':'
#else
# define PATH_SEP ' '
#endif
static int path_parse(char ***p)
{
int npth;
@ -872,7 +878,7 @@ static int path_parse(char ***p)
tmp = (char*)pth;
npth = 1; /* path component count */
while (1) {
tmp = strchr(tmp, ':');
tmp = strchr(tmp, PATH_SEP);
if (!tmp)
break;
tmp++;
@ -885,7 +891,7 @@ static int path_parse(char ***p)
res[0] = tmp = xstrdup(pth);
npth = 1;
while (1) {
tmp = strchr(tmp, ':');
tmp = strchr(tmp, PATH_SEP);
if (!tmp)
break;
*tmp++ = '\0'; /* ':' -> '\0' */

View File

@ -6512,6 +6512,7 @@ static void restore_redirects(int squirrel[])
static char *find_in_path(const char *arg)
{
char *ret = NULL;
#ifndef __GNO__
const char *PATH = get_local_var_value("PATH");
if (!PATH)
@ -6538,6 +6539,13 @@ static char *find_in_path(const char *arg)
}
PATH = end + 1;
}
#else
ret = buildPath(arg);
if (ret && access(ret, F_OK) != 0) {
free(ret);
return NULL;
}
#endif
return ret;
}