(dopipe): Check whether argument starts with '|'. Simplify convoluted
logic. Improve error messages.
This commit is contained in:
parent
17d6997d4e
commit
2456a71acf
1 changed files with 11 additions and 9 deletions
|
@ -236,25 +236,27 @@ dopipe(char *p)
|
||||||
{
|
{
|
||||||
char *tag;
|
char *tag;
|
||||||
|
|
||||||
if (*p == '|')
|
if (*p++ != '|') {
|
||||||
p++;
|
fprintf(stderr, "WARNING! Weird pipe %s", p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tag = gettag(p);
|
tag = gettag(p);
|
||||||
while (*p && isspace(*p))
|
|
||||||
p++;
|
|
||||||
if (tag == NULL) {
|
if (tag == NULL) {
|
||||||
fprintf(stderr, "WARNING! Server attempted to run: %s\n", p);
|
fprintf(stderr, "WARNING! Server attempted to run: %s\n", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
free(tag);
|
||||||
|
|
||||||
|
for (; *p && isspace(*p); p++) ;
|
||||||
if (*p == 0) {
|
if (*p == 0) {
|
||||||
fprintf(stderr, "Null program name after redirect\n");
|
fprintf(stderr, "Redirection lacks a command\n");
|
||||||
free(tag);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((pipe_fp = popen(p, "w")) == NULL) {
|
if ((pipe_fp = popen(p, "w")) == NULL) {
|
||||||
fprintf(stderr, "Pipe open failed\n");
|
fprintf(stderr, "Can't redirect to pipe %s: %s\n",
|
||||||
perror(p);
|
p, strerror(errno));
|
||||||
}
|
}
|
||||||
free(tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue