From patchwork Sat Jul 27 05:35:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13743613 Received: from impout006.msg.chrl.nc.charter.net (impout006aa.msg.chrl.nc.charter.net [47.43.20.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15EDA4A05 for ; Sat, 27 Jul 2024 05:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058623; cv=none; b=dnaSkIkRtaHhrpz/Mo8n/nOf6cvNN1bZUFRWjn+p5ON8lCZ0rZK2j3Xm+cjPI4uqamrYNnA3u1VPQqMJ76Svq7ZRVwEYqTmGC1m82t2zmYleW+yqq8sH1BPUhFMsrtBkjkuzp45jkeYJV8y9JMRw+8LDZonKWbZEcCxZ/oRhnrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058623; c=relaxed/simple; bh=f/zEj2Q8nYAd0LgZGNGp1BBaw/9NlFMvyDydHW0xqA8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KhMV8SPLlnA1R402qEZ2/Lx3nGV+BsgU9JQX62B/lot0BaVZmAKI6MfBYl+Rf+ECju4d8ajvBmC2OH1CwktfMEmVdw00oWKiiUO/6yrBfpSLB9bLMSTPUszmTv6clb64CeXgmOKV8pTblpzE7pz3VrvX1pHK4OhTGxmZrHXKBgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net; spf=pass smtp.mailfrom=charter.net; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b=i4aj9gU0; arc=none smtp.client-ip=47.43.20.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=charter.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b="i4aj9gU0" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Xa5PsVwc3l0ATXa5Uszqvy; Sat, 27 Jul 2024 05:35:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1722058524; bh=f/zEj2Q8nYAd0LgZGNGp1BBaw/9NlFMvyDydHW0xqA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i4aj9gU0qUZAwyqSpHF3oGzCNzuKurNKxwjnzPexB3a7WkvxkYGWUsx0sMlpmqRbS MliV+uF6fKpqM0hadh8UuBkWvGH81PnQZ4rOgIuxk6Yf6jqL0hs1W4yIiVtmk4/H9o rh8JpXUHtU4qLl+y9hQ96qz2WHPqqNbsP8ETOIh1WEVEqEZQ8MaTmDOnQqJ4zzT4y+ H8y7tJTPKoq7E/IRLX5pJp57IPiSWi0ePSjqI2QScWpPf3aBEADu7omwa5+jr9anG3 rAMGgIrPCYP1UoMGxOrPizIEt1yTi/pyxOAFXTj8SfS5dX7aumRU70pNqK6Tc0yPxq zMcOaBmkQe8Yw== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=b6u04MGx c=1 sm=1 tr=0 ts=66a4871c a=4h87Vkt5vDwEBqoyvSX4iA==:117 a=4h87Vkt5vDwEBqoyvSX4iA==:17 a=BCjA09oAAAAA:8 a=A1X0JdhQAAAA:8 a=g-X_pVf7e692ChHf-W0A:9 a=jYKBPJSq9nmHKCndOPe9:22 a=Df3jFdWbhGDLdZNm0fyq:22 From: Eric Sunshine To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Rub=C3=A9n_Justo?= , Phillip Wood , Kyle Lippincott , Eric Sunshine Subject: [PATCH v3 1/5] t3430: drop unnecessary one-shot "VAR=val shell-func" invocation Date: Sat, 27 Jul 2024 01:35:05 -0400 Message-ID: <20240727053509.34339-2-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240727053509.34339-1-ericsunshine@charter.net> References: <20240726081522.28015-1-ericsunshine@charter.net> <20240727053509.34339-1-ericsunshine@charter.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CMAE-Envelope: MS4xfALL2qgYNgcLJosD6UCSqRCVA0MXWSKU88g9ZFCCy0U3KxxMiCQuBsQPcaBSpsUf8PW3W9SdhrKnizOrPWrOrtV5NdJEakER+lTzg5a5f5LjT/FVBiAz X739psTUNcixZaG+XvH4wI3bBLa3PNVfcOnNNDgnc+z5ZyvD/98ePS8Y5BjTkV0WFfTsn1UudtEqc4Ynh9TYhAtpyUyb9hBzZEAeJAtJALR2f2PxkcT5c/EI Z7lJXB6OTaV442cOUOuYezd/Jnie6xCuOE1fcYzwoCV3FK7k7gbIeXh/kPf0DS2qH1t+NcN8VntP6SUqqXCGPOt3RaFh0/SwRxMEiLbr8P6D3gEXVEbgyJv0 CLgGwdP2 From: Eric Sunshine The behavior of a one-shot environment variable assignment of the form "VAR=val cmd" is unspecified according to POSIX when "cmd" is a shell function. Indeed the behavior differs between shell implementations and even different versions of the same shell. One such problematic behavior is that, with some shells, the assignment will outlive the invocation of the function, thus may potentially impact subsequent commands in the test, as well as subsequent tests. A common way to work around the problem is to wrap a subshell around the one-shot assignment, thus ensuring that the assignment is short-lived. In this test, the subshell is employed precisely for this purpose; other side-effects of the subshell, such as losing the effect of `test_tick` which is invoked by `test_commit`, are immaterial. These days, we can take advantage of `test_commit --author` to more clearly convey that the test is interested only in overriding the author of the commit. Signed-off-by: Eric Sunshine --- t/t3430-rebase-merges.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 36ca126bcd..2aa8593f77 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -392,8 +392,7 @@ test_expect_success 'refuse to merge ancestors of HEAD' ' test_expect_success 'root commits' ' git checkout --orphan unrelated && - (GIT_AUTHOR_NAME="Parsnip" GIT_AUTHOR_EMAIL="root@example.com" \ - test_commit second-root) && + test_commit --author "Parsnip " second-root && test_commit third-root && cat >script-from-scratch <<-\EOF && pick third-root From patchwork Sat Jul 27 05:35:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13743614 Received: from impout006.msg.chrl.nc.charter.net (impout006aa.msg.chrl.nc.charter.net [47.43.20.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44C0017C66 for ; Sat, 27 Jul 2024 05:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058623; cv=none; b=KXh0ObF+gzxx0gJpBv8wiJcSvrFHTj+XDEgEZPmJCbgCLjgljkZ33bohXc84O097Ap1eH9aOFoQC2utrGBoUc+uz4CEPJnDGH2cqIk5Wynv8vk+AC+HiZzTGpjj4W8mv4k71jK1Zx/80i3cuLPnqsIksKepor6cZrqfsUvdxBxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058623; c=relaxed/simple; bh=uhvhiVp19ZnmmaqA5XO2XNQje8OD1SKmOKy953nKHyA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tZ9NvmHzUlbex/LBcSf3GmrWljY2Yx1w593xCzvrzazwXjcHbkev5sgPprXJoQZEyYCF5y2CQ3aS3Gei/PNQWP85ZufUSDHKvDlwm1obz/5wKRoacpAVFiNte3yumsUQ+yY1FczQnICbjRgeLKLPSkYgNMcuOniizj72QkkObJ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net; spf=pass smtp.mailfrom=charter.net; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b=WNrCsV2q; arc=none smtp.client-ip=47.43.20.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=charter.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b="WNrCsV2q" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Xa5PsVwc3l0ATXa5Uszqw8; Sat, 27 Jul 2024 05:35:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1722058525; bh=uhvhiVp19ZnmmaqA5XO2XNQje8OD1SKmOKy953nKHyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WNrCsV2qk24n4MZu/5uYNlW3t4qfD3Gu45HNp36vEhzb2dQI7A4gGGK8dFtBwFSKe UfOUmVXSO4QIiaDjT96pRBpoIBdihCqS9AGJvpHGbE5OgoFmfQKm7jeG5RYDuRs9wn wWlKduQuFN1xAEwEaRLuwdfxkVdrg5u7uNMr8kTkVx45MLynOB7B+rDyPgfas88iuX XKkNESoMrxP6HSh0bVsR1SSODeCDqjG85r2vHShZomHPYSHZIv82P8PzTtv2bmv0X4 NSAErsgf7ucFxdE6NwUsQpboo8SVK+cCxlV2aPvB7GnGUdH3durfX1E6MIy+Nk/71I BP5sHG4COTAwg== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=b6u04MGx c=1 sm=1 tr=0 ts=66a4871d a=4h87Vkt5vDwEBqoyvSX4iA==:117 a=4h87Vkt5vDwEBqoyvSX4iA==:17 a=BCjA09oAAAAA:8 a=1bBlrEcKPFs_eYj-LMwA:9 a=jYKBPJSq9nmHKCndOPe9:22 From: Eric Sunshine To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Rub=C3=A9n_Justo?= , Phillip Wood , Kyle Lippincott , Eric Sunshine Subject: [PATCH v3 2/5] t4034: fix use of one-shot variable assignment with shell function Date: Sat, 27 Jul 2024 01:35:06 -0400 Message-ID: <20240727053509.34339-3-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240727053509.34339-1-ericsunshine@charter.net> References: <20240726081522.28015-1-ericsunshine@charter.net> <20240727053509.34339-1-ericsunshine@charter.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CMAE-Envelope: MS4xfDQ4lbQ+rhVLcEemJah5/f2ue7BEFdlFOM4YzRBxrwU87UvUbD1wgqXH1m5WpSOqPj5YK/5iusS/QmsFUvcjNc2JCkE304Ox7tD4YGl8FDhab4FhYcOs tnKhBK0/tkfCIr3eelAnmaH8rA0kH5YOTOtsp55RLHbOc3cuEDJHWCNzx7AiZ993GEIw03OObi8ZdPFEf+d2+1ejXjvRwDkWZ31+KZd9PKzCsXluRWAuhQ6r WzVg16KYhHnKzMMfJCmTWSvQyA3M9mkF4L7u5OOoQ+7Iqt/FSI1h2DqDrzNSLNW9x2raoCrGV7j7jcn9mIfTXPBhl6AU+LAFFEc7SNgsHRM5qpV0oOy9o5id ZWcT2jJB From: Eric Sunshine The behavior of a one-shot environment variable assignment of the form "VAR=val cmd" is unspecified according to POSIX when "cmd" is a shell function. Indeed the behavior differs between shell implementations and even different versions of the same shell, thus should be avoided. Signed-off-by: Eric Sunshine --- t/t4034-diff-words.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh index 74586f3813..4dcd7e9925 100755 --- a/t/t4034-diff-words.sh +++ b/t/t4034-diff-words.sh @@ -70,7 +70,7 @@ test_language_driver () { word_diff --color-words ' test_expect_success "diff driver '$lang' in Islandic" ' - LANG=is_IS.UTF-8 LANGUAGE=is LC_ALL="$is_IS_locale" \ + test_env LANG=is_IS.UTF-8 LANGUAGE=is LC_ALL="$is_IS_locale" \ word_diff --color-words ' } From patchwork Sat Jul 27 05:35:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13743616 Received: from impout006.msg.chrl.nc.charter.net (impout006aa.msg.chrl.nc.charter.net [47.43.20.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF5401864C for ; Sat, 27 Jul 2024 05:37:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058625; cv=none; b=QYYD/3ZzvH/43aMBJnsXqBO6FGZnLmcFUtSQUVgmK/6uQ/4C+qIjdWqTHLmzLpFF5WKJuwaDT8keYlYYaJYmEW+KJWDwDRWGU9aPqUYLmQUqEyTumG5zrsrKDKTmW7XISx60onzfFuMEZhYJjbDORdWMcKIY0r7lut+xEwuAeVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058625; c=relaxed/simple; bh=ZYHJVIPMvFBn/IdnBF1bHTcG0un+pIqZrgt8WFubTuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rlqgcMhleswFjT2HLx8GhXq682qBtRfueffhCdykUnYa2lglDUUqS6aTHFCoVYPMXvIWB1+zLRNlA7ZlK7xf30I/qIIRT7uM6s17h66NQ3jiLr6uKVBbyRgJPi7BKfv8KOdBfvl08XROiPQpoaaOJ/fu/wA2Ji4YrmsAm/w5XLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net; spf=pass smtp.mailfrom=charter.net; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b=vRNqctJY; arc=none smtp.client-ip=47.43.20.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=charter.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b="vRNqctJY" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Xa5PsVwc3l0ATXa5VszqwJ; Sat, 27 Jul 2024 05:35:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1722058525; bh=ZYHJVIPMvFBn/IdnBF1bHTcG0un+pIqZrgt8WFubTuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vRNqctJYpBOselrEkfA9+Q8ua6VkxgD3EZr7IBzlBRYwg5yMpQcUTyshwBrClD9pr dsFaP+gO9NgeX9yEtv3/ufo+RSN7b/JZaE6MAV184PcfFzCPbS9uxSZ5tDa/A2U7bV abgMDle5aWmiNVFY5efSm5FDxIjRtVxZrakKOwTNcpduTA1q2FdFdnmBRlKrB5oULO s47Y6C+19+gIpobxQXpsE9pemW/D0TfQnP2HAFBsTl0SlAHysjXcor+1sy6uCKVlbh g6M5z/HkyiZCqP5xB/PZa/+ohdgQMsoqT049YjVmAjTWKkJbQEhm2aOUid95C7mJKR NS5nv7czsuP6A== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=b6u04MGx c=1 sm=1 tr=0 ts=66a4871d a=4h87Vkt5vDwEBqoyvSX4iA==:117 a=4h87Vkt5vDwEBqoyvSX4iA==:17 a=BCjA09oAAAAA:8 a=VwQbUJbxAAAA:8 a=tEj-drDq3PFC0m8d5k0A:9 a=jYKBPJSq9nmHKCndOPe9:22 a=AjGcO6oz07-iQ99wixmX:22 From: Eric Sunshine To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Rub=C3=A9n_Justo?= , Phillip Wood , Kyle Lippincott , Eric Sunshine Subject: [PATCH v3 3/5] check-non-portable-shell: loosen one-shot assignment error message Date: Sat, 27 Jul 2024 01:35:07 -0400 Message-ID: <20240727053509.34339-4-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240727053509.34339-1-ericsunshine@charter.net> References: <20240726081522.28015-1-ericsunshine@charter.net> <20240727053509.34339-1-ericsunshine@charter.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CMAE-Envelope: MS4xfDQ4lbQ+rhVLcEemJah5/f2ue7BEFdlFOM4YzRBxrwU87UvUbD1wgqXH1m5WpSOqPj5YK/5iusS/QmsFUvcjNc2JCkE304Ox7tD4YGl8FDhab4FhYcOs tnKhBK0/tkfCIr3eelAnmaH8rA0kH5YOTOtsp55RLHbOc3cuEDJHWCNzx7AiZ993GEIw03OObi8ZdPFEf+d2+1ejXjvRwDkWZ31+KZd9PKzCsXluRWAuhQ6r WzVg16KYhHnKzMMfJCmTWSvQyA3M9mkF4L7u5OOoQ+7Iqt/FSI1h2DqDrzNSLNW9x2raoCrGV7j7jcn9mIfTXPBhl6AU+LAFFEc7SNgsHRM5qpV0oOy9o5id ZWcT2jJB From: Eric Sunshine When a0a630192d (t/check-non-portable-shell: detect "FOO=bar shell_func", 2018-07-13) added the check for one-shot environment variable assignment for shell functions, the primary reason given for avoiding them was that, under some shells, the assignment outlives the invocation of the shell function, thus could potentially negatively impact subsequent commands in the same test, as well as subsequent tests. However, it has recently become apparent that this is not the only potential problem with one-shot assignments and shell functions. Another problem is that some shells do not actually export the variable to commands which the function invokes[1]. More significantly, however, the behavior of one-shot assignments with shell functions is not specified by POSIX[2]. Given this new understanding, the presented error message ("assignment extends beyond 'shell_func'") is too specific and potentially misleading. Address this by emitting a less specific error message. (Note that the wording "is not portable" is chosen over the more specific "behavior not specified by POSIX" for consistency with almost all other error message issued by this "lint" script.) [1]: https://lore.kernel.org/git/xmqqbk2p9lwi.fsf_-_@gitster.g/ [2]: https://lore.kernel.org/git/xmqq34o19jj1.fsf@gitster.g/ Signed-off-by: Eric Sunshine --- t/check-non-portable-shell.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index b2b28c2ced..179efaa39d 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -50,7 +50,7 @@ sub err { /\blocal\s+[A-Za-z0-9_]*=\$([A-Za-z0-9_{]|[(][^(])/ and err q(quote "$val" in 'local var=$val'); /^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and - err '"FOO=bar shell_func" assignment extends beyond "shell_func"'; + err '"FOO=bar shell_func" is not portable'; $line = ''; # this resets our $. for each file close ARGV if eof; From patchwork Sat Jul 27 05:35:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13743615 Received: from impout006.msg.chrl.nc.charter.net (impout006aa.msg.chrl.nc.charter.net [47.43.20.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF50618643 for ; Sat, 27 Jul 2024 05:37:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058624; cv=none; b=pRCG93c3v9gAk/dyXxdy7ExP4CucB+HPnTosA5W77PRlcDHdHUa7x07PFmQaSWM/8IuIDJDepN6Tl7uuTvWWL+s4HKaPNelP+Pa0cJoyXWysKu0ZWsJoVBU936R7D4iCenKhFDhZQTVUzHaFc+h/9B6xLuGcEKOv0uHd7NV18to= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058624; c=relaxed/simple; bh=P15zAzVOaT//fKV13JnbXzzP6hN0uwUzzuuzckT4lRc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eR7Gwr33YVSO8J2TXWtaTDnTa9MrGKLAMHgHwJ/Yl9CvXxmtdJkaEPITx1BBnzgXxeqmenaue/OQgGQ7kI8pQ6zuWr0ulqbq3xLNxFhrLmkx40LqbBfWE7GhoUDacsmYU8pNAXq4geulBZJesiwpyDDLtXcOStaDEqCITkik9fk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net; spf=pass smtp.mailfrom=charter.net; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b=Z/ygiZ9/; arc=none smtp.client-ip=47.43.20.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=charter.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b="Z/ygiZ9/" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Xa5PsVwc3l0ATXa5VszqwX; Sat, 27 Jul 2024 05:35:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1722058526; bh=P15zAzVOaT//fKV13JnbXzzP6hN0uwUzzuuzckT4lRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z/ygiZ9/dQMIPGcAT8X0USShebMaTWf2/aolB/DtWkhGVSt1kJ8njUqHK/9ampRzl ESAt0E55xfsG0PYMVcNsXUi4wcXuAW1PdmApKvcaWrVVMxA+hg20HJCT009P1Eedo8 Yk3RBpeCJJoTzVKhyBV3CGbs7NYX/N9QT6rOsFXTsD0WmZ8sIIsmHSi2vt9Y82aBoz XTJ9n2qDpD/3OJu9NLpSDai3mBsnvrTN/D35oFpJVgwh8UDw02b2SMkAFGQbKD1Rb6 Gld/PACOHMn70KSCoUA33ucB+8atam+sydlb0GkqHoQv9wqLN1ZXhDnPNTP86ROpxC V1aX51+Rd+ylg== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=b6u04MGx c=1 sm=1 tr=0 ts=66a4871e a=4h87Vkt5vDwEBqoyvSX4iA==:117 a=4h87Vkt5vDwEBqoyvSX4iA==:17 a=BCjA09oAAAAA:8 a=xjmMxo3dIE4o5O_OhqsA:9 a=jYKBPJSq9nmHKCndOPe9:22 From: Eric Sunshine To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Rub=C3=A9n_Justo?= , Phillip Wood , Kyle Lippincott , Eric Sunshine Subject: [PATCH v3 4/5] check-non-portable-shell: suggest alternative for `VAR=val shell-func` Date: Sat, 27 Jul 2024 01:35:08 -0400 Message-ID: <20240727053509.34339-5-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240727053509.34339-1-ericsunshine@charter.net> References: <20240726081522.28015-1-ericsunshine@charter.net> <20240727053509.34339-1-ericsunshine@charter.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CMAE-Envelope: MS4xfBJY2PIqsITYWAVvn4y+J5Jc2KoYlau1VQl6LMdL6dirhj0Rle7wBJ1s54b1HW6wCoOi8kch1LJoq+kWB9MsQPqlv0IQaYtJclDtDVh3oOQGwv2eACNy B9GS0RfaFQRIrrCnVyWZECWqY1bbuiRZgbP1xaHtVgy1VFGUjFyjoRpzhTSQpFAFSYNKOKkGbg+ecqh+7od3bTzOpMuYzl3i4hj1vOZKnpA2wrcRCuJBVJ8L /wrX8OB/lt8RovtK7//QLMIJ0iG/53nbq1+ZaxLGqzcBNUkTJhGFLnr2rP2oCyFYPCaZkLvrlsrb6ubms5rveiYdbQ4lkUJ6Hb/vYqgkKByxAWCJJGVH0gZ1 7s8zIzV0 From: Eric Sunshine Most problems reported by check-non-portable-shell are accompanied by advice suggesting how the test author can repair the problem. For instance: error: egrep/fgrep obsolescent (use grep -E/-F) However, when one-shot variable assignment is detected when calling a shell function (i.e. `VAR=val shell-func`), the problem is reported, but no advice is given. The lack of advice is particularly egregious since neither the problem nor the workaround are likely well-known by newcomers to the project writing tests for the first time. Address this shortcoming by recommending the use of `test_env` which is tailor made for this specific use-case. Signed-off-by: Eric Sunshine --- t/check-non-portable-shell.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index 179efaa39d..903af14294 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -50,7 +50,7 @@ sub err { /\blocal\s+[A-Za-z0-9_]*=\$([A-Za-z0-9_{]|[(][^(])/ and err q(quote "$val" in 'local var=$val'); /^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and - err '"FOO=bar shell_func" is not portable'; + err '"FOO=bar shell_func" is not portable (use test_env FOO=bar shell_func)'; $line = ''; # this resets our $. for each file close ARGV if eof; From patchwork Sat Jul 27 05:35:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13743617 Received: from impout006.msg.chrl.nc.charter.net (impout006aa.msg.chrl.nc.charter.net [47.43.20.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1AD11A286 for ; Sat, 27 Jul 2024 05:37:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058625; cv=none; b=IVI8+XAfMd0q/t5xyEb+KH/XdkjRyP3si41knjB+tNVoIzcgDk9K9AAfNsfcwXNuwAngiLK+BehP6fJglFXYlHPFyc0AciDiWHFE/JPR6sxFNLg7n0ZAjxnOcu/o9Sx5ei63TCI9JnD/iVorwu6O+vQoO/AOBHBFM2axi2rfE1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722058625; c=relaxed/simple; bh=OOcab8Ehb4vNL9I39sBRFIRtuKJg+c6G5Lx9ZoG7/Xk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S74PHU21z/N4AXDOmMwuc69skPKWtl+Jp2ys6ZISyZfhF0DEFZHb32b+m1Mut8lURZt06ufGPZQHNzz36D7Kn3kcs5lW0ue6sZZ7AqH1xlxQwVj+/WvQ9Vkfj2tILBOYn5nD2vr2Rzc6AvQXHe32mTrjsMNKjr9IU3PFB3glLfM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net; spf=pass smtp.mailfrom=charter.net; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b=N2r2IhND; arc=none smtp.client-ip=47.43.20.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=charter.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=charter.net header.i=@charter.net header.b="N2r2IhND" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Xa5PsVwc3l0ATXa5Wszqwc; Sat, 27 Jul 2024 05:35:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1722058526; bh=OOcab8Ehb4vNL9I39sBRFIRtuKJg+c6G5Lx9ZoG7/Xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N2r2IhND4Jp2qmCYgOLNa/hHio6sVbYDR/QWx/sY2ZUFqwWACmOTS9EMwi01nq3Bc l0X9znmoyVxXMoYKr5Y+HwWpsJkZk/9VAMofk+clhKXWL8hIuQ0EKU0LyAez43nrkI JTsarkvLEAv/IatLjE8Wk7d4TUxOK7f3Eczwg3cyJO/oXxdt1okrxuNMTKjWie5hvC F3l6nvTtpUbTzpoTr1W/dFmiZzo7J+7Mv3/xMvdTSWJoPl/v6xDxC6tM1QI3SQaMUX O3XfCXMdD5u/Gl/hQo5SPK2u0pOIm3jZN3VsVBF84IQMkYXoThXJpOnED856KHbcvh Qo1Ponhb/0aNw== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=b6u04MGx c=1 sm=1 tr=0 ts=66a4871e a=4h87Vkt5vDwEBqoyvSX4iA==:117 a=4h87Vkt5vDwEBqoyvSX4iA==:17 a=BCjA09oAAAAA:8 a=46kcjEQM1sjoQMFQ3FAA:9 a=jYKBPJSq9nmHKCndOPe9:22 From: Eric Sunshine To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Rub=C3=A9n_Justo?= , Phillip Wood , Kyle Lippincott , Eric Sunshine Subject: [PATCH v3 5/5] check-non-portable-shell: improve `VAR=val shell-func` detection Date: Sat, 27 Jul 2024 01:35:09 -0400 Message-ID: <20240727053509.34339-6-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240727053509.34339-1-ericsunshine@charter.net> References: <20240726081522.28015-1-ericsunshine@charter.net> <20240727053509.34339-1-ericsunshine@charter.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CMAE-Envelope: MS4xfBJY2PIqsITYWAVvn4y+J5Jc2KoYlau1VQl6LMdL6dirhj0Rle7wBJ1s54b1HW6wCoOi8kch1LJoq+kWB9MsQPqlv0IQaYtJclDtDVh3oOQGwv2eACNy B9GS0RfaFQRIrrCnVyWZECWqY1bbuiRZgbP1xaHtVgy1VFGUjFyjoRpzhTSQpFAFSYNKOKkGbg+ecqh+7od3bTzOpMuYzl3i4hj1vOZKnpA2wrcRCuJBVJ8L /wrX8OB/lt8RovtK7//QLMIJ0iG/53nbq1+ZaxLGqzcBNUkTJhGFLnr2rP2oCyFYPCaZkLvrlsrb6ubms5rveiYdbQ4lkUJ6Hb/vYqgkKByxAWCJJGVH0gZ1 7s8zIzV0 From: Eric Sunshine The behavior of a one-shot environment variable assignment of the form "VAR=val cmd" is unspecified according to POSIX when "cmd" is a shell function. Indeed the behavior differs between shell implementations and even different versions of the same shell, thus should be avoided. As such, check-non-portable-shell.pl warns when it detects such usage. However, a limitation of the check is that it only detects such invocations when variable assignment (i.e. `VAR=val`) is the first thing on the line. Thus, it can easily be fooled by an invocation such as: echo X | VAR=val shell-func Address this shortcoming by loosening the check so that the variable assignment can be recognized even when not at the beginning of the line. Signed-off-by: Eric Sunshine --- t/check-non-portable-shell.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index 903af14294..6ee7700eb4 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -49,7 +49,7 @@ sub err { /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)'; /\blocal\s+[A-Za-z0-9_]*=\$([A-Za-z0-9_{]|[(][^(])/ and err q(quote "$val" in 'local var=$val'); - /^\s*([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and + /\b([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and !/test_env.+=/ and exists($func{$4}) and err '"FOO=bar shell_func" is not portable (use test_env FOO=bar shell_func)'; $line = ''; # this resets our $. for each file