mirror of
https://github.com/sheumann/hush.git
synced 2025-01-10 16:29:44 +00:00
Changes to support GNO-style PATH in type and source commands, and in tab completion.
This commit is contained in:
parent
4c37e05f0c
commit
6dfc5eadb3
@ -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' */
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user