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 4D13B158046 for ; Tue, 14 Oct 2025 12:59:49 +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 38AD534102E for ; Tue, 14 Oct 2025 12:59:49 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 9A92A110576; Tue, 14 Oct 2025 12:59:36 +0000 (UTC) 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) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 8BB87110574 for ; Tue, 14 Oct 2025 12:59:36 +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) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 462BF340EC7 for ; Tue, 14 Oct 2025 12:59:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 84B2C3AFC 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: <1760446750.972eb63cbb3187528cd9d02f97696b3e7319eaed.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: 972eb63cbb3187528cd9d02f97696b3e7319eaed 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: 3c83f390-8517-4ef8-88e5-067626868c2d X-Archives-Hash: e4d52ce49e595a04997230b642fc2ad7 commit: 972eb63cbb3187528cd9d02f97696b3e7319eaed Author: Kerin Millar plushkava net> AuthorDate: Tue Oct 14 09:15:34 2025 +0000 Commit: Sam James gentoo org> CommitDate: Tue Oct 14 12:59:10 2025 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=972eb63c Don't let _update_columns() restore IFS as '' where previously unset One of the methods by which the _update_columns() function is able to determine the dimensions of the terminal is to execute the stty(1) utility. Should it elect to do so, it backs up the value of the 'IFS' variable to one named 'genfun_ifs' before setting 'IFS' appropriately. Then, after stty(1) has been executed, the prior value of 'IFS' is restored from 'genfun_ifs'. All of which is fundamentally incorrect. $ unset -v IFS $ echo "IFS=${IFS-unset}" IFS=unset $ f() { old_ifs=$IFS; IFS=$old_ifs; }; f $ echo "IFS=${IFS-unset}" IFS= Note how, despite IFS having been unset, the function 'restores' it by assigning the null string. But these two states are not equivalent. The specification exacts the following two requirements. "If the IFS variable is set and has an empty string as its value, no field splitting shall occur." "If the IFS variable is unset, then for the purposes of this section, but without altering the value of the variable, its value shall be considered to contain the three single-byte characters , , and from the portable character set, all of which are IFS white-space characters." Address this issue by jettisoning the 'genfun_ifs' variable and declaring 'IFS' as a local variable instead. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> functions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions.sh b/functions.sh index 5b49ce8..ed049c1 100644 --- a/functions.sh +++ b/functions.sh @@ -868,6 +868,8 @@ _update_columns() _update_columns() { + local IFS + # Two optimisations are applied. Firstly, the rate at which # updates can be performed is throttled to intervals of half a # second. Secondly, if running on bash then the COLUMNS variable @@ -887,11 +889,9 @@ _update_columns() set -- 0 "${COLUMNS}" else # This use of stty(1) is portable as of POSIX-1.2024. - genfun_ifs=${IFS} IFS=' ' # shellcheck disable=2046 set -- $(stty size 2>/dev/null) - IFS=${genfun_ifs} fi [ "$#" -eq 2 ] && is_int "$2" && [ "$2" -gt 0 ] && genfun_cols=$2 }