mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2024-06-07 19:29:42 +00:00
clean up error reporting.
This commit is contained in:
parent
edcb832c13
commit
ed341db9fa
|
@ -85,25 +85,19 @@ int read_fd(phase1 &p, int fd) {
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
size = read(fd, buffer, sizeof(buffer));
|
size = read(fd, buffer, sizeof(buffer));
|
||||||
if (size == 0) break;
|
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
if (errno == EINTR) continue;
|
if (errno == EINTR) continue;
|
||||||
perror("read: ");
|
perror("read: ");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
p.process(buffer, buffer + size);
|
if (size == 0) p.finish();
|
||||||
|
else p.process(buffer, buffer + size);
|
||||||
} catch(std::exception &ex) {
|
} catch(std::exception &ex) {
|
||||||
fprintf(stderr, "%s\n", ex.what());
|
fprintf(stderr, "### %s\n", ex.what());
|
||||||
p.reset();
|
p.reset();
|
||||||
}
|
}
|
||||||
}
|
if (size == 0) break;
|
||||||
|
|
||||||
try {
|
|
||||||
p.finish();
|
|
||||||
} catch(std::exception &ex) {
|
|
||||||
fprintf(stderr, "%s\n", ex.what());
|
|
||||||
p.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -240,7 +234,7 @@ int interactive(Environment &env, phase1 &p1, phase2& p2) {
|
||||||
p1.process(s);
|
p1.process(s);
|
||||||
|
|
||||||
} catch(std::exception &ex) {
|
} catch(std::exception &ex) {
|
||||||
fprintf(stderr, "%s\n", ex.what());
|
fprintf(stderr, "### %s\n", ex.what());
|
||||||
p1.reset();
|
p1.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +243,7 @@ int interactive(Environment &env, phase1 &p1, phase2& p2) {
|
||||||
try {
|
try {
|
||||||
p1.finish();
|
p1.finish();
|
||||||
} catch(std::exception &ex) {
|
} catch(std::exception &ex) {
|
||||||
fprintf(stderr, "%s\n", ex.what());
|
fprintf(stderr, "### %s\n", ex.what());
|
||||||
p1.reset();
|
p1.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +365,7 @@ int make(int argc, char **argv) {
|
||||||
ptr->execute(e, fds);
|
ptr->execute(e, fds);
|
||||||
} catch (execution_of_input_terminated &ex) {
|
} catch (execution_of_input_terminated &ex) {
|
||||||
control_c = 0;
|
control_c = 0;
|
||||||
fprintf(stderr, "%s\n", ex.what());
|
fprintf(stderr, "### %s\n", ex.what());
|
||||||
if (e.exit())
|
if (e.exit())
|
||||||
exit(ex.status());
|
exit(ex.status());
|
||||||
e.status(ex.status(), false);
|
e.status(ex.status(), false);
|
||||||
|
@ -523,7 +517,7 @@ int main(int argc, char **argv) {
|
||||||
} catch (execution_of_input_terminated &ex) {
|
} catch (execution_of_input_terminated &ex) {
|
||||||
control_c = 0;
|
control_c = 0;
|
||||||
if (!(ptr->terminal() && ++iter == v.end())) {
|
if (!(ptr->terminal() && ++iter == v.end())) {
|
||||||
fprintf(stderr, "%s\n", ex.what());
|
fprintf(stderr, "### %s\n", ex.what());
|
||||||
}
|
}
|
||||||
e.status(ex.status(), false);
|
e.status(ex.status(), false);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user