=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/which/which.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- src/usr.bin/which/which.c 2011/03/11 04:30:21 1.17 +++ src/usr.bin/which/which.c 2013/04/10 02:57:20 1.18 @@ -1,4 +1,4 @@ -/* $OpenBSD: which.c,v 1.17 2011/03/11 04:30:21 guenther Exp $ */ +/* $OpenBSD: which.c,v 1.18 2013/04/10 02:57:20 guenther Exp $ */ /* * Copyright (c) 1997 Todd C. Miller @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -69,24 +70,9 @@ if (argc == 0) usage(); - /* - * which(1) uses user's $PATH. - * whereis(1) uses user.cs_path from sysctl(3). - */ if (strcmp(__progname, "whereis") == 0) { - int mib[2]; - progmode = PROG_WHEREIS; - mib[0] = CTL_USER; - mib[1] = USER_CS_PATH; - if (sysctl(mib, 2, NULL, &n, NULL, 0) == -1) - err(1, "unable to get length of user.cs_path"); - if (n == 0) - errx(1, "user.cs_path was zero length!"); - if ((path = (char *)malloc(n)) == NULL) - errx(1, "can't allocate memory."); - if (sysctl(mib, 2, path, &n, NULL, 0) == -1) - err(1, "unable to get user.cs_path"); + path = _PATH_STDPATH; } else { if ((path = getenv("PATH")) == NULL) err(1, "can't get $PATH from environment");