Module Name: src
Committed By: christos
Date: Mon May 17 17:01:16 UTC 2010
Modified Files:
src/usr.bin/make: main.c
Log Message:
put back canonicalization, but avoid doing it for files that don't contain /
>From dholland
To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/usr.bin/make/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.186 src/usr.bin/make/main.c:1.187
--- src/usr.bin/make/main.c:1.186 Mon May 10 11:54:21 2010
+++ src/usr.bin/make/main.c Mon May 17 13:01:16 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $ */
+/* $NetBSD: main.c,v 1.187 2010/05/17 17:01:16 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.187 2010/05/17 17:01:16 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.187 2010/05/17 17:01:16 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -900,7 +900,22 @@
* MFLAGS also gets initialized empty, for compatibility.
*/
Parse_Init();
- p1 = argv[0];
+ if (argv[0][0] == '/' || strchr(argv[0], '/') == NULL) {
+ /*
+ * Leave alone if it is an absolute path, or if it does
+ * not contain a '/' in which case we need to find it in
+ * the path, like execvp(3) and the shells do.
+ */
+ p1 = argv[0];
+ } else {
+ /*
+ * A relative path, canonicalize it.
+ */
+ p1 = realpath(argv[0], mdpath);
+ if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) {
+ p1 = argv[0]; /* realpath failed */
+ }
+ }
Var_Set("MAKE", p1, VAR_GLOBAL, 0);
Var_Set(".MAKE", p1, VAR_GLOBAL, 0);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);