Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Aug 1995 23:44:06 +0200
From:      Wolfram Schneider <wosch@cs.tu-berlin.de>
To:        current@freebsd.org
Subject:   make(1) extension for SHELL COMMANDS
Message-ID:  <199508132144.XAA25996@localhost>

next in thread | raw e-mail | index | archive | help

from new manpage:
     If the first or first three characters of the command line are `@' and/or
     `-', and/or `!', the command is treated specially.  A `@' causes the com-
     mand not to be echoed before it is executed.  A `-' causes any non-zero
     exit status of the command line to be ignored.  A `!' causes make to use
     exec and not /bin/sh. This makes live with quotes much easier.



Example:

date:
        date "+%D%M (test)\n"


use /bin/sh due '('


date:
        !date "+%D%M (test)\n"

use explicit exec.


--
Wolfram Schneider <wosch@cs.tu-berlin.de>
http://hyperg.cs.tu-berlin.de/C~wosch


--- 1.1	1995/08/13 16:54:38
+++ compat.c	1995/08/13 21:28:49
@@ -148,7 +148,8 @@
     char    	  *cmdStart;	/* Start of expanded command */
     register char *cp;
     Boolean 	  silent,   	/* Don't print command */
-		  errCheck; 	/* Check errors */
+		  errCheck, 	/* Check errors */
+                  ForceExec;    /* Don't use /bin/sh, use exec */
     union wait 	  reason;   	/* Reason for child's death */
     int	    	  status;   	/* Description of child's death */
     int	    	  cpid;	    	/* Child actually found */
@@ -171,6 +172,7 @@
 
     silent = gn->type & OP_SILENT;
     errCheck = !(gn->type & OP_IGNORE);
+    ForceExec = gn->type & OP_FORCE_EXEC;
 
     cmdNode = Lst_Member (gn->commands, (ClientData)cmd);
     cmdStart = Var_Subst (NULL, cmd, gn, FALSE);
@@ -198,11 +200,13 @@
 	return(0);
     }
 
-    while ((*cmd == '@') || (*cmd == '-')) {
+    while ((*cmd == '@') || (*cmd == '-') || (*cmd == '!')) {
 	if (*cmd == '@') {
 	    silent = TRUE;
-	} else {
+	} else if (*cmd == '-'){
 	    errCheck = FALSE;
+	} else {
+	    ForceExec = TRUE;
 	}
 	cmd++;
     }
@@ -235,7 +239,16 @@
     if (noExecute) {
 	return (0);
     }
-    
+
+    /*
+     * to force an exec and not /bin/sh ignore result from
+     * meta character checking
+     */
+    if (ForceExec) {
+	while(*cp)
+	    cp++;
+    }
+
     if (*cp != '\0') {
 	/*
 	 * If *cp isn't the null character, we hit a "meta" character and
@@ -259,6 +272,18 @@
 	 */
 	av = brk_string(cmd, &argc);
 	av += 1;
+	if (ForceExec && DEBUG(JOB)) { 
+	    char **a = av;
+
+	    fprintf(stdout, "ForceExec %s\n", cmd);
+	    fprintf(stdout, "execvp(\"%s\"", *av);
+            for(a = av; *a; a++) {
+                fprintf(stdout, ", \"%s\"", *a);
+            }
+            fprintf(stdout, ");\nargc: %d\n", argc);
+	}
+
+
     }
     
     local = TRUE;
--- 1.1	1995/08/13 17:30:42
+++ job.c	1995/08/13 17:30:53
@@ -447,10 +447,10 @@
     /*
      * Check for leading @' and -'s to control echoing and error checking.
      */
-    while (*cmd == '@' || *cmd == '-') {
+    while (*cmd == '@' || *cmd == '-' || *cmd == '!') {
 	if (*cmd == '@') {
 	    shutUp = TRUE;
-	} else {
+	} else if (*cmd == '-'){
 	    errOff = TRUE;
 	}
 	cmd++;
--- 1.1	1995/08/13 21:06:29
+++ make.1	1995/08/13 21:40:23
@@ -236,10 +236,12 @@
 .Ql Ic ::
 operator is used.
 .Pp
-If the first or first two characters of the command line are
+If the first or first three characters of the command line are
 .Ql Ic @
 and/or
 .Ql Ic \- ,
+and/or
+.Ql Ic ! ,
 the command is treated specially.
 A
 .Ql Ic @
@@ -247,6 +249,10 @@
 A
 .Ql Ic \-
 causes any non-zero exit status of the command line to be ignored.
+A
+.Ql Ic !
+causes make to use exec and not /bin/sh. This makes live with
+quotes and meta characters much easier.
 .Sh VARIABLE ASSIGNMENTS
 Variables in make are much like variables in the shell, and, by tradition,
 consist of all upper-case letters.
--- 1.1	1995/08/13 17:08:19
+++ make.h	1995/08/13 17:08:26
@@ -179,6 +179,7 @@
 				     * state of the -n or -t flags */
 #define OP_JOIN 	0x00000400  /* Target is out-of-date only if any of its
 				     * children was out-of-date */
+#define OP_FORCE_EXEC   0x00000800  /* Don't use /bin/sh, use exec */
 #define OP_INVISIBLE	0x00004000  /* The node is invisible to its parents.
 				     * I.e. it doesn't show up in the parents's
 				     * local variables. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508132144.XAA25996>