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

View File

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