aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.18
-rw-r--r--build.c24
2 files changed, 18 insertions, 14 deletions
diff --git a/build.1 b/build.1
index 2655ce0..59a2ce5 100644
--- a/build.1
+++ b/build.1
@@ -6,10 +6,7 @@
.Nd follow embedded build instructions
.Sh SYNOPSIS
.Nm
-.Op Fl d
-.Op Fl d
-.Op Fl d
-.Op Fl f
+.Op Fl dddfq
.Ar file
.Op Ar ...
.Sh DESCRIPTION
@@ -24,6 +21,9 @@ The
.Fl f
flag disables modification time checks,
forcing the build process.
+The
+.Fl q
+flag disables the printing of executed commands.
.Pp
.Nm
is decidedly not a
diff --git a/build.c b/build.c
index f0bfb29..01e7f90 100644
--- a/build.c
+++ b/build.c
@@ -8,7 +8,6 @@
#include <sys/wait.h>
#include <unistd.h>
-#define USAGE "usage: %s file [...]\n", name
#define d(...) do{ if(dflag > 0) \
fprintf(stderr, __VA_ARGS__); } while(0);
#define dd(...) do{ if(dflag > 1) \
@@ -36,7 +35,7 @@ main(int argc, char *argv[])
{
char *b, buf[MAXBUF], *cmd[MAXCMDS], *d, *dep, *name, *tgt, wd[MAXPATH];
FILE *fp;
- int c, dflag, fflag, i, icmd, j, s;
+ int c, dflag, fflag, i, icmd, j, qflag, s;
struct stat sb, ssb;
/* Allocate memory. */
@@ -59,8 +58,8 @@ main(int argc, char *argv[])
/* Process command-line flags (debug, force). */
name = argv[0];
- dflag = fflag = 0;
- while((c = getopt(argc, argv, "df")) != -1)
+ dflag = fflag = qflag = 0;
+ while((c = getopt(argc, argv, "dfq")) != -1)
switch(c){
case 'd':
dflag++;
@@ -68,14 +67,16 @@ main(int argc, char *argv[])
case 'f':
fflag = 1;
break;
+ case 'q':
+ qflag = 1;
+ break;
default:
- fprintf(stderr, USAGE);
- return 1;
+ goto usage;
}
argc -= optind;
argv += optind;
if(argc == 0){
- fprintf(stderr, USAGE);
+usage: fprintf(stderr, "usage: %s [-dddfq] file [...]\n", name);
return 1;
}
@@ -208,10 +209,13 @@ build:
* print executed commands.
*/
buf[0] = 0;
- strcat(buf, "set -ex\n");
+ if(qflag)
+ strcat(buf, "set -e\n");
+ else
+ strcat(buf, "set -ex\n");
for(j = 0; j < icmd; j++){
- strncat(buf, cmd[j], MAXBUF-1);
- strncat(buf, "\n", MAXBUF-1);
+ strncat(buf, cmd[j], MAXCMD-1);
+ strncat(buf, "\n", MAXCMD-1);
}
s = system(buf);