Skip to content

Commit

Permalink
14080 cw does not honor dmake silent flag
Browse files Browse the repository at this point in the history
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
rcgoodfellow authored and Dan McDonald committed Sep 21, 2021
1 parent 21bcbe6 commit c3d5f7c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 4 additions & 0 deletions usr/src/cmd/make/bin/main.cc
Expand Up @@ -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);
Expand Down
26 changes: 23 additions & 3 deletions usr/src/tools/cw/cw.c
Expand Up @@ -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, "+ ");

Expand Down

0 comments on commit c3d5f7c

Please sign in to comment.