I think using _PATH_DEFPATH in the absence of PATH is better.
- todd
Index: Makefile
===================================================================
RCS file: /cvs/src/usr.bin/which/Makefile,v
retrieving revision 1.8
diff -u -p -u -r1.8 Makefile
--- Makefile 15 Apr 2013 16:34:19 -0000 1.8
+++ Makefile 3 Dec 2013 23:48:18 -0000
@@ -58,10 +58,9 @@ The following environment variables affe
A colon-separated list of directories in which to find executables.
If
.Ev PATH
-is not set, and the given name is not a fully qualified
-or relative pathname,
+is not set or is empty,
.Nm
-will fail.
+will use the system's default search path.
.El
.Sh EXIT STATUS
The
Index: which.c
===================================================================
RCS file: /cvs/src/usr.bin/which/which.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 which.c
--- which.c 29 Dec 2015 19:04:46 -0000 1.22
+++ which.c 14 Jan 2016 21:51:01 -0000
@@ -74,8 +74,8 @@ main(int argc, char *argv[])
progmode = PROG_WHEREIS;
path = _PATH_STDPATH;
} else {
- if ((path = getenv("PATH")) == NULL)
- err(1, "can't get $PATH from environment");
+ if ((path = getenv("PATH")) == NULL || *path == '\0')
+ path = _PATH_DEFPATH;
}
/* To make access(2) do what we want */