version 1.15, 2001/02/07 22:55:47 |
version 1.16, 2001/02/08 15:02:01 |
|
|
if (!args || !*args) |
if (!args || !*args) |
local_do_shell("ls"); |
local_do_shell("ls"); |
else { |
else { |
char *buf = xmalloc(8 + strlen(args) + 1); |
int len = sizeof("/bin/ls ") + strlen(args) + 1; |
|
char *buf = xmalloc(len); |
|
|
/* XXX: quoting - rip quoting code from ftp? */ |
/* XXX: quoting - rip quoting code from ftp? */ |
sprintf(buf, "/bin/ls %s", args); |
snprintf(buf, len, "/bin/ls %s", args); |
local_do_shell(buf); |
local_do_shell(buf); |
|
xfree(buf); |
} |
} |
} |
} |
|
|
|
|
if (!*cp) { |
if (!*cp) { |
*cpp = cp; |
*cpp = cp; |
*path = NULL; |
*path = NULL; |
|
|
return (0); |
return (0); |
} |
} |
|
|
|
|
error("Unterminated quote"); |
error("Unterminated quote"); |
goto fail; |
goto fail; |
} |
} |
|
|
if (cp == end) { |
if (cp == end) { |
error("Empty quotes"); |
error("Empty quotes"); |
goto fail; |
goto fail; |
} |
} |
|
|
*cpp = end + 1 + strspn(end + 1, WHITESPACE); |
*cpp = end + 1 + strspn(end + 1, WHITESPACE); |
} else { |
} else { |
/* Read to end of filename */ |
/* Read to end of filename */ |
end = strpbrk(cp, WHITESPACE); |
end = strpbrk(cp, WHITESPACE); |
if (end == NULL) |
if (end == NULL) |
end = strchr(cp, '\0'); |
end = strchr(cp, '\0'); |
|
|
*cpp = end + strspn(end, WHITESPACE); |
*cpp = end + strspn(end, WHITESPACE); |
} |
} |
|
|
|
|
*path = xmalloc(i + 1); |
*path = xmalloc(i + 1); |
memcpy(*path, cp, i); |
memcpy(*path, cp, i); |
(*path)[i] = '\0'; |
(*path)[i] = '\0'; |
|
|
return(0); |
return(0); |
|
|
fail: |
fail: |
*path = NULL; |
*path = NULL; |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
|
|
debug("XXX: P = \"%s\"", p); |
debug("XXX: P = \"%s\"", p); |
|
|
cp = strrchr(p, '/'); |
cp = strrchr(p, '/'); |
|
|
if (cp == NULL) { |
if (cp == NULL) { |
*ifp = xstrdup(p); |
*ifp = xstrdup(p); |
return(0); |
return(0); |
|
|
} |
} |
|
|
*cpp = cp; |
*cpp = cp; |
|
|
return(cmdnum); |
return(cmdnum); |
} |
} |
|
|
|
|
xfree(path1); |
xfree(path1); |
if (path2) |
if (path2) |
xfree(path2); |
xfree(path2); |
|
|
return(0); |
return(0); |
} |
} |
|
|