summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Goodfellow <ryan.goodfellow@oxide.computer>2021-09-16 03:19:30 +0000
committerDan McDonald <danmcd@joyent.com>2021-09-21 15:09:45 -0400
commitc3d5f7c437ff92ea7e52cd66a2b9b892f58d46b0 (patch)
tree8ece07e2fb491b87400e26227f050b75f302def7
parent21bcbe6e4903d8521ec66863bf0c21d9ed378cff (diff)
downloadillumos-joyent-c3d5f7c437ff92ea7e52cd66a2b9b892f58d46b0.tar.gz
14080 cw does not honor dmake silent flag
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Robert Mustacchi <rm@fingolfin.org> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/make/bin/main.cc4
-rw-r--r--usr/src/tools/cw/cw.c26
2 files changed, 27 insertions, 3 deletions
diff --git a/usr/src/cmd/make/bin/main.cc b/usr/src/cmd/make/bin/main.cc
index d635ad86ee..8c35d06494 100644
--- a/usr/src/cmd/make/bin/main.cc
+++ b/usr/src/cmd/make/bin/main.cc
@@ -1906,6 +1906,10 @@ read_files_and_state(int argc, char **argv)
* Before reading makefile we do not know exactly which mode
* (posix or not) is used. So prepare two MAKEFLAGS strings
* for both posix and solaris modes because they are different.
+ *
+ * Note: cw depends on short flags with no arguments appearing
+ * first in MAKEFLAGS. If this behavior changes, cw will need to
+ * be updated.
*/
INIT_STRING_FROM_STACK(makeflags_string, buffer);
INIT_STRING_FROM_STACK(makeflags_string_posix, buffer_posix);
diff --git a/usr/src/tools/cw/cw.c b/usr/src/tools/cw/cw.c
index 594da6fc70..ccd520207b 100644
--- a/usr/src/tools/cw/cw.c
+++ b/usr/src/tools/cw/cw.c
@@ -1439,14 +1439,34 @@ prepctx(cw_ictx_t *ctx)
static int
invoke(cw_ictx_t *ctx)
{
- char **newargv;
+ char **newargv, *makeflags;
int ac;
struct ae *a;
- if ((newargv = calloc(sizeof (*newargv), ctx->i_ae->ael_argc + 1)) ==
- NULL)
+ newargv = calloc(ctx->i_ae->ael_argc + 1, sizeof (*newargv));
+ if (newargv == NULL)
nomem();
+ /*
+ * Check to see if the silent make flag is present (-s), if so, do not
+ * echo. The MAKEFLAGS environment variable is set by dmake. By
+ * observation it appears to place short flags without any arguments
+ * first followed by any long form flags or flags with arguments.
+ */
+ makeflags = getenv("MAKEFLAGS");
+ if (makeflags != NULL) {
+ size_t makeflags_len = strlen(makeflags);
+ for (size_t i = 0; i < makeflags_len; i++) {
+ if (makeflags[i] == 's') {
+ ctx->i_flags &= ~CW_F_ECHO;
+ break;
+ }
+ /* end of short flags */
+ if (makeflags[i] == ' ')
+ break;
+ }
+ }
+
if (ctx->i_flags & CW_F_ECHO)
(void) fprintf(stderr, "+ ");