aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.112
-rw-r--r--build.c9
2 files changed, 19 insertions, 2 deletions
diff --git a/build.1 b/build.1
index 3d8fcda..cf66324 100644
--- a/build.1
+++ b/build.1
@@ -76,6 +76,18 @@ in the same shell process.
This means that you can keep state across multiple commands.
Note that all commands are executed
regardless of the exit status of previous commands.
+.Pp
+.Nm
+exits with a positive status if a command failed.
+Note that it checks the status
+of the entire command sent to the shell,
+not the individual command lines.
+To emulate the behavior of
+.Xr make 1 ,
+which fails if any individual command line fails,
+you can use
+.Ql set -e
+in your command line.
.
.Sh EXAMPLES
.Pp
diff --git a/build.c b/build.c
index 8b4e060..fc21925 100644
--- a/build.c
+++ b/build.c
@@ -32,7 +32,7 @@ main(int argc, char *argv[])
{
char *b, buf[MAXBUF], *cmd[MAXCMDS], *d, *dep, *name, *tgt;
FILE *fp;
- int c, dflag, fflag, i, icmd, j;
+ int c, dflag, fflag, i, icmd, j, s, status;
struct stat sb, ssb;
/* allocate memory */
@@ -46,6 +46,7 @@ main(int argc, char *argv[])
if (!dep) err(1, "malloc");
tgt[0] = dep[0] = 0;
+ status = 0;
/* process arguments */
name = argv[0];
@@ -162,11 +163,15 @@ build:
strncat(buf, cmd[j], MAXBUF-1);
strncat(buf, "\n", MAXBUF-1);
}
- system(buf);
+ s = system(buf);
+ if (s != -1)
+ status += s;
done:
fclose(fp);
}
+
+ return status > 0;
}
void