From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2C51315808B for ; Sat, 5 Oct 2024 04:15:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 901FCE29E9; Sat, 5 Oct 2024 04:15:26 +0000 (UTC) Received: from smtp.gentoo.org (smtp.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 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7805CE29E9 for ; Sat, 5 Oct 2024 04:15:26 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 37298342FE7 for ; Sat, 5 Oct 2024 04:15:25 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9252E27F5 for ; Sat, 5 Oct 2024 04:15:22 +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: <1724355466.116645c35885a32b994e49794aa60e9c8216ba9b.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 116645c35885a32b994e49794aa60e9c8216ba9b X-VCS-Branch: master Date: Sat, 5 Oct 2024 04:15:22 +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: 12dd8836-98fa-44e3-b917-0b85f67a1b02 X-Archives-Hash: 80a04bb82222bc0770a9d16adc2a271c commit: 116645c35885a32b994e49794aa60e9c8216ba9b Author: Kerin Millar plushkava net> AuthorDate: Wed Aug 14 06:23:25 2024 +0000 Commit: Sam James gentoo org> CommitDate: Thu Aug 22 19:37:46 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=116645c3 Have whenceforth() work around a word splitting bug in OpenBSD sh Consider the case where IFS consists of a single character whose value is neither , nor . The following example employs the colon, since it is the character that the whenceforth() function relies upon during word splitting. $ bash -c 'IFS=":"; path=":"; set -- $path; echo "$# ${1@Q}"' 1 '' The result is very much as expected because the colon in path serves as a terminator for an empty field. Now, let's consider how many fields are produced in OpenBSD sh as a consequence of word splitting. $ sh -c 'IFS=":"; path=":"; set -- $path; echo "$#"' 0 For the time being, work around it by having whenceforth() repeat the field terminator for the affected edge cases, which are two in number. With this change, the test suite is now able to pass for: - loksh 7.5 - oksh 7.5 - sh (OpenBSD 7.5) Signed-off-by: Kerin Millar plushkava.net> functions.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index 6cf7439..1a87100 100644 --- a/functions.sh +++ b/functions.sh @@ -759,7 +759,15 @@ whenceforth() # Relative command paths must be searched for in PATH. # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03 case ${PATH} in - ''|*:) + ''|:) + # Work around a bug in OpenBSD sh and + # its ports. Where IFS has a value of + # ":", splitting a word having the same + # value produces no words at all. Handle + # it by repeating the field terminator. + path=:: + ;; + *:) path=${PATH}: ;; *)