From nobody Sun Aug 30 07:06:26 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hXjpd2jMVz6qR5v for ; Sun, 30 Aug 2026 07:06:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hXjpc510Rz3ZNC for ; Sun, 30 Aug 2026 07:06:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788073592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=avpzY/4L70X7ud6/M42PBhEgwIqZYeQOIblbSZRMYlA=; b=UBBOHvWdNwmhNBSDz2Fdl/X4HhwbJdL+3AcZQOvFxdCibWL7jFtyf9ADEHZULZJqLNsCPq THpZ/uC+c+gi9lQgM8ze8RAryN8/hKYZIVTj/TOfc5yhZ3m7i0VA6V8x0ggPouyRU//CXn X3X/W+cBj0kcrh0GP+7PdHJAo7nTFL0Lu2CcdNCegM4lu6FSvkbVUw6dCYuWbenELoWroy rx4r0pJsSqIEMfuFFZzyXQaZMfuFT987sZSGlYfWn/nRVY5JgGRPIpOgGYqJijYzA9iMVg 7B4vXzFEx297XEvEH6lUbXUqbhgogwdP3Duuz2tr5oAwOvNVXQ6yuvjqqQwRYw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788073592; a=rsa-sha256; cv=none; b=kaUfZ049KRJuPCYSEvoURwhlDVES6dGwKrJ6ubfhIfu7uWhEZObsvTkpH4f640I9s1hxdb obA8pNBJjab1DHppV+Evi5FFeycmL7T9wbli51VkD7sUNjMkh0q3Rx9gNIYhI9nAmvCNmd O8W5aHFfVq9eXa6Yuy4RSkYI2OlieHqSzW4LNs5ISrptCnHEaBuMKOhRg9e28enkR5YJeh sla4KqraVQjTg6qYd4G0zswtvYc5iuu6e9anWkKlRUk9MH9J4iPYWzgRdS+RYfhoASnVoe K+sL2K984DBe0dbcbgrx/a3hcuTY/iugnGme0gL/TkRlDUrwZucsWB/XV49eqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788073592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=avpzY/4L70X7ud6/M42PBhEgwIqZYeQOIblbSZRMYlA=; b=lcRdhhr5c29A5dGd763dDUULfF8LHEwCixx3RA46uUteWoKbw8BMb1/rGsv+IliCU9h3cT BEro70DdLifZt9qnL/JSz3xopSV4aJrUPoKfLpvyTq7qrjwx8ZdbI+1Qv578Q/tXMC6Xeb pF1VH9MM/+2RhAqjbE13jdiWqL+/rItqq3eje99r6B92TOr5yUsM4vzS3KEfwLH599tCc4 uunJPsaAH6TxuxHHH5k5L1BLBEOvmMrsOwSrKNDONmECtAhl2gix4oV78GWXQBkoHULB25 ZuTs//KOU3VLlaHyi7E4CqNRXKLDhaLgYgSt7FPT5CA4gG0ASIIMMPVjPscY8A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hXjpb5rqWzqJ for ; Sun, 30 Aug 2026 07:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 399b8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 30 Aug 2026 07:06:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Fernando Apeste=?utf-8?Q?gu=C3=ADa?= Subject: git: 0b3fc7f448c4 - main - Revert "whereis(1): Respect PORTSDIR variable" List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fernape X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0b3fc7f448c43efc2d197fcdc73c3d1a62f55406 Auto-Submitted: auto-generated Date: Sun, 30 Aug 2026 07:06:26 +0000 Message-Id: <6a93d672.399b8.61043ddc@gitrepo.freebsd.org> The branch main has been updated by fernape: URL: https://cgit.FreeBSD.org/src/commit/?id=0b3fc7f448c43efc2d197fcdc73c3d1a62f55406 commit 0b3fc7f448c43efc2d197fcdc73c3d1a62f55406 Author: Fernando ApesteguĂ­a AuthorDate: 2026-08-30 07:05:43 +0000 Commit: Fernando ApesteguĂ­a CommitDate: 2026-08-30 07:05:43 +0000 Revert "whereis(1): Respect PORTSDIR variable" This reverts commit edadc3f9051595a9c2e693d8ab666a50b9e7a21a. --- usr.bin/whereis/whereis.1 | 4 -- usr.bin/whereis/whereis.c | 118 +++++++++++++++++++++------------------------- 2 files changed, 53 insertions(+), 69 deletions(-) diff --git a/usr.bin/whereis/whereis.1 b/usr.bin/whereis/whereis.1 index 1b6adaeaf077..90922ce61db5 100644 --- a/usr.bin/whereis/whereis.1 +++ b/usr.bin/whereis/whereis.1 @@ -72,10 +72,6 @@ including all the subdirectories of .Pa /usr/src and .Pa /usr/ports . -If the environment variable -.Ev PORTSDIR -is defined and points to a directory then all its subdirectories -are included in the search of program sources. .Pp The following options are available: .Bl -tag -width indent diff --git a/usr.bin/whereis/whereis.c b/usr.bin/whereis/whereis.c index afc099276dfe..8de56b9cf654 100644 --- a/usr.bin/whereis/whereis.c +++ b/usr.bin/whereis/whereis.c @@ -312,76 +312,64 @@ defaults(void) abort(); nele = 0; decolonify(b, &sourcedirs, &nele); - ccharp path_ports; - if ((cp = getenv("PORTSDIR")) != NULL) { - b = strdup(cp); - if (b == NULL) - abort(); + + if (stat(PATH_PORTS, &sb) == -1) { + if (errno == ENOENT) + /* no /usr/ports, we are done */ + return; + err(EX_OSERR, "stat(" PATH_PORTS ")"); } - ccharp ports_locations[2] = {PATH_PORTS, cp}; - int i; - for (i = 0; i < 2; i++) { - path_ports = ports_locations[i]; - if (!path_ports) - continue; - if (stat(path_ports, &sb) == -1) { - if (errno == ENOENT) - /* no /usr/ports, we are done */ - continue; - err(EX_OSERR, "stat(%s)", path_ports); - } - if ((sb.st_mode & S_IFMT) != S_IFDIR) - /* This is not a directory, ignore */ + if ((sb.st_mode & S_IFMT) != S_IFDIR) + /* /usr/ports is not a directory, ignore */ + return; + if (access(PATH_PORTS, R_OK | X_OK) != 0) + return; + if ((dir = opendir(PATH_PORTS)) == NULL) + err(EX_OSERR, "opendir" PATH_PORTS ")"); + while ((dirp = readdir(dir)) != NULL) { + /* + * Not everything below PATH_PORTS is of + * interest. First, all dot files and + * directories (e. g. .snap) can be ignored. + * Also, all subdirectories starting with a + * capital letter are not going to be + * examined, as they are used for internal + * purposes (Mk, Tools, ...). This also + * matches a possible CVS subdirectory. + * Finally, the distfiles subdirectory is also + * special, and should not be considered to + * avoid false matches. + */ + if (dirp->d_name[0] == '.' || + /* + * isupper() not used on purpose: the + * check is supposed to default to the C + * locale instead of the current user's + * locale. + */ + (dirp->d_name[0] >= 'A' && dirp->d_name[0] <= 'Z') || + strcmp(dirp->d_name, "distfiles") == 0) continue; - if (access(path_ports, R_OK | X_OK) != 0) + if ((b = malloc(sizeof PATH_PORTS + 1 + dirp->d_namlen)) + == NULL) + abort(); + strcpy(b, PATH_PORTS); + strcat(b, "/"); + strcat(b, dirp->d_name); + if (stat(b, &sb) == -1 || + (sb.st_mode & S_IFMT) != S_IFDIR || + access(b, R_OK | X_OK) != 0) { + free(b); continue; - if ((dir = opendir(path_ports)) == NULL) - err(EX_OSERR, "opendir %s)", path_ports); - while ((dirp = readdir(dir)) != NULL) { - /* - * Not everything below path_ports is of - * interest. First, all dot files and - * directories (e. g. .snap) can be ignored. - * Also, all subdirectories starting with a - * capital letter are not going to be - * examined, as they are used for internal - * purposes (Mk, Tools, ...). This also - * matches a possible CVS subdirectory. - * Finally, the distfiles subdirectory is also - * special, and should not be considered to - * avoid false matches. - */ - if (dirp->d_name[0] == '.' || - /* - * isupper() not used on purpose: the - * check is supposed to default to the C - * locale instead of the current user's - * locale. - */ - (dirp->d_name[0] >= 'A' && dirp->d_name[0] <= 'Z') || - strcmp(dirp->d_name, "distfiles") == 0) - continue; - if ((b = malloc(strlen(path_ports) + 1 + dirp->d_namlen)) - == NULL) - abort(); - strcpy(b, path_ports); - strcat(b, "/"); - strcat(b, dirp->d_name); - if (stat(b, &sb) == -1 || - (sb.st_mode & S_IFMT) != S_IFDIR || - access(b, R_OK | X_OK) != 0) { - free(b); - continue; - } - sourcedirs = realloc(sourcedirs, - (nele + 2) * sizeof(char *)); - if (sourcedirs == NULL) - abort(); - sourcedirs[nele++] = b; - sourcedirs[nele] = NULL; } - closedir(dir); + sourcedirs = realloc(sourcedirs, + (nele + 2) * sizeof(char *)); + if (sourcedirs == NULL) + abort(); + sourcedirs[nele++] = b; + sourcedirs[nele] = NULL; } + closedir(dir); } }