From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A9DFE158046 for ; Tue, 14 Oct 2025 12:59:41 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 964B0340F39 for ; Tue, 14 Oct 2025 12:59:41 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 1D8F41104B5; Tue, 14 Oct 2025 12:59:35 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 148011104B5 for ; Tue, 14 Oct 2025 12:59:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BE19C340EBA for ; Tue, 14 Oct 2025 12:59:34 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 382EC3AE4 for ; Tue, 14 Oct 2025 12:59:33 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1760446749.f425d58d16a71736f6f8f5f3d41d2c898e9b0a92.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh test-functions X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: f425d58d16a71736f6f8f5f3d41d2c898e9b0a92 X-VCS-Branch: master Date: Tue, 14 Oct 2025 12:59:33 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 511c7351-1b7e-4807-bf9b-5ce68f90c06d X-Archives-Hash: 498b92be5bbcaa5d75a8258cea1b8ecd commit: f425d58d16a71736f6f8f5f3d41d2c898e9b0a92 Author: Kerin Millar plushkava net> AuthorDate: Tue Oct 14 06:46:01 2025 +0000 Commit: Sam James gentoo org> CommitDate: Tue Oct 14 12:59:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=f425d58d Improve the chdir() implementation Re-implement the chdir() function in a manner that resembles the sample code provided by POSIX in the APPLICATION USAGE section of cd(1). This introduces two behavioural changes: - the -P option shall now be specified - executing chdir() without any arguments shall now raise an error Thus, increment GENFUN_API_LEVEL to 2. Link: https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/cd.html#tag_20_14_16 Link: https://austingroupbugs.net/view.php?id=1047 Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> functions.sh | 24 ++++++++++++------------ test-functions | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/functions.sh b/functions.sh index 771a7bc..0c98e84 100644 --- a/functions.sh +++ b/functions.sh @@ -91,22 +91,22 @@ assign() # chdir() { - if [ "$#" -eq 1 ]; then - case $1 in - '') - _warn_for_args chdir "$1" - return 1 - ;; - -) - set -- ./- - esac - fi if [ "${BASH}" ]; then # shellcheck disable=3044 shopt -u cdable_vars fi # shellcheck disable=1007,2164 - CDPATH= cd -- "$@" + case $1 in + '') + printf >&2 'chdir: null directory\n' + false + ;; + /*) + cd -P "$1" + ;; + *) + CDPATH= cd -P "./$1" + esac } # @@ -1035,7 +1035,7 @@ _warn_for_args() # This shall be incremented by one upon any change being made to the public API. # It was introduced by gentoo-functions-1.7 with an initial value of 1. # shellcheck disable=2034 -GENFUN_API_LEVEL=1 +GENFUN_API_LEVEL=2 # If genfun_basedir is unset, set genfun_prefix to the value of EPREFIX, as it # was at the time of installing gentoo-functions, before setting genfun_basedir diff --git a/test-functions b/test-functions index 16f9481..0aa2f21 100755 --- a/test-functions +++ b/test-functions @@ -50,6 +50,7 @@ test_local() { test_chdir() { set -- \ ge 1 '' \ + ge 1 N/A \ ge 1 grandchild \ ge 1 var \ eq 0 -L \