From patchwork Fri Jul 26 08:15:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13742459 Received: from impout003.msg.chrl.nc.charter.net (impout003aa.msg.chrl.nc.charter.net [47.43.20.27]) (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 F22CA176AB3 for ; Fri, 26 Jul 2024 08:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981874; cv=none; b=UR2qEjRk+7PSdWSPhTzICuOcZ69VRatmu8ueLdv2nmJ8+Homl6MrzF5/5P3qLL95aT/+B4UWy/JP3fCm03DkYza3feSqRrSHTP87vx+qUbbhSPGR4SkIWa9noqPkZfySY5PvMb5uxmgAhv7Ek1/or6fO2TrMIuxv3LCZlnhQIl0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981874; c=relaxed/simple; bh=yYQ7iwQgtZohuEsFFW9qx5CQe8gGMAJVekBILsKL9Bc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DkQv73GumRQ7yqlV+fVC/T1JR09lXrCUw7oQL2iIlv39RefVdKeBjCKVyZfJGooJjhb+tjjlNBNKl6mxKjoV55cQ+sgv5/TuGHmS1CULVLAMs0yYlM0Dpi2mtQPcbDYH8TuE5ppYZr5d6SZudATa0taO52ez7E5XhSrfBNfnf0E= 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=Ey5gQ3kn; arc=none smtp.client-ip=47.43.20.27 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="Ey5gQ3kn" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id XG7MsyipKvFCWXG7ZsRqj3; Fri, 26 Jul 2024 08:16:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721981773; bh=yYQ7iwQgtZohuEsFFW9qx5CQe8gGMAJVekBILsKL9Bc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ey5gQ3knBxQPc6Zxadx3voSy3QO3fpnqYhkjTB0GvRWRd6dIyr3/NFgtD/jxk4Y+W D2rHUVHoNO15XwSmdQFqN84oJvZgysONzwBedXIHQbM2u4C+EKYBzOarG5lgwNnFqr 9XK+kb228QunOzjTmnleOQDqSdFs/CpNMajHIWODb+B7dpXm7yPjmbeybj/WblGAyv bmVaw/qcWhnCvQrVydG0vW2T3HasFekrfHOr7zLRk0Iu641PbxbDe0EeL57sbRPOQO bbFB8mUwpsgYaQ3ifuGZ2ttLqUwRJIXd1EOk4zxicgJ27facteFLnLnd84zX94ttbd 2j9NiT8TJ3PlQ== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=O+w/vg9W c=1 sm=1 tr=0 ts=66a35b4d 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 v2 1/5] t3430: drop unnecessary one-shot "VAR=val shell-func" invocation Date: Fri, 26 Jul 2024 04:15:18 -0400 Message-ID: <20240726081522.28015-2-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726081522.28015-1-ericsunshine@charter.net> References: <20240722065915.80760-1-ericsunshine@charter.net> <20240726081522.28015-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: MS4xfIRDs6Davw2aWHZtwOmj7fCu2dRTcTfecn094yLQcuIHWLubkDiIfVughfkcgbqQhkjMCvT6vwtT02OzPDBBnin0vqgBPhYDKbWyGgGRoxg/ti/Cx0+w bfkCBcItcolPIrBEzmjVB55kS0GYWkIj2HEdfBguVxCWQbCXZJxA3gDOmVfkWK7MGk5XX6+SwVV9UL0GfRo0/z8f9xmb1gxiuig6FvGTaRgInCed72SgcLUE BKFjYWBSVnvmKl4u2PjxydS/jbGlOfFYJDwG6aooKBhyp76uuKEWBD8HWvbhlU9qGMjWpAe7e9EZM5L37ohBprtRDnhxDlNbgtqWZV+Hv7OOz5qB/oKfMjX7 ms0BJPG2 From: Eric Sunshine The behavior of a one-shot environment variable assignment of the form "VAR=val cmd" is undefined 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 ill-defined 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 Fri Jul 26 08:15:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13742455 Received: from impout003.msg.chrl.nc.charter.net (impout003aa.msg.chrl.nc.charter.net [47.43.20.27]) (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 F2276176AA9 for ; Fri, 26 Jul 2024 08:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981873; cv=none; b=LHfzGPneQfBc+EkEFoXVf5G3QIOLwR2TpAYxS7dceKjMoRW4MLwB+yIWqpXJAFV+Sam4g0IKBTt0yTEWwU7SxglpA41W8DUn56eGhMxMYRilDocymD4I9j95WvY34eaGuRfjJJ63jjr/OV/umSH5I/0U40ySr0uF5n6sZGEeHW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981873; c=relaxed/simple; bh=0Jf0WGx6OBntC8VbAFDxwmkndCCqn7i8vhMb5KBdMps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zq9M2+xW1p1vWZ8YPiat0OAysdg3lfkEQmjWYHpFZEMuKOYyuJWQWl61UXD8qlwWDf+YCw+AxgAaOQGX5AJBOWwliFdAjPbSxIgjyTaCUBI7xwaA+kC+BR6PVgkL2w+a3e7nG/yDgbFap0iNb9MC7jGsXpiFFQCiK8+JxmE70J8= 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=RLra4Bd8; arc=none smtp.client-ip=47.43.20.27 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="RLra4Bd8" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id XG7MsyipKvFCWXG7ZsRqj9; Fri, 26 Jul 2024 08:16:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721981774; bh=0Jf0WGx6OBntC8VbAFDxwmkndCCqn7i8vhMb5KBdMps=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RLra4Bd83v+HZ/5qIzfu4SDoYiXyYZPOcNFLKpU4+PytZS/ieoxfRlPu1gbL7UEGU 9K2PNvLj8ymHiaxo6K9xJYATPOpjjZJyyPmriIvR2OhIwECJ5gscyYBxsp2YLm+hUL /pGTSZs2x/N2jZPECXj4oz3Fc8js7quDzbCbxtx0+0EVN2xwcOPh4eMWh3LgJ5SqjF UDnJgKnIfei2u/jLVUqw0J4YLHw0IoBtx3FSI3noyvDNw5/wDafsB8LgA4UbS4dk2+ 1RUpItHdL6eYGmQb15ryBFr5mK8uWW9akdLNx+oPfFyQslz4BWbla09d4VWVruUjH1 xvULombT5vPmQ== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=O+w/vg9W c=1 sm=1 tr=0 ts=66a35b4e 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 v2 2/5] t4034: fix use of one-shot variable assignment with shell function Date: Fri, 26 Jul 2024 04:15:19 -0400 Message-ID: <20240726081522.28015-3-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726081522.28015-1-ericsunshine@charter.net> References: <20240722065915.80760-1-ericsunshine@charter.net> <20240726081522.28015-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: MS4xfCZ7xnSSVoddY7wDS7a9UL3rdRG1jOIJargj9BEkfqQzFXcaEqnpmVouXaKKtdw7/Jyy+032g33Ixq+rY33GJHdod8FeH2+k7388fg3Q3LptxynKITXz Wq1tOO8olzfFH8kZ52m1UrcHVfMpef28wb8iAxwCOxhmrf3gO4mRc58CdyHT9+Ac1B6tErITJQ3f4u2YudTa/gc0Z9AGKdviHV8VYHe03lrpfMK0m/gwPImq 1SMO5PusgVG7NmdFSEKD0lrr4pjW+7j2nVBgWOhEE2VEpKBynxtr3lRksVFzTVn1J+AkoZe4slZogTckJaZy42nOhWGEedsY2+2tC8XqOFdQyGl4zQal2YRO u6iqgkEz From: Eric Sunshine The behavior of a one-shot environment variable assignment of the form "VAR=val cmd" is undefined 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 Fri Jul 26 08:15:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13742457 Received: from impout003.msg.chrl.nc.charter.net (impout003aa.msg.chrl.nc.charter.net [47.43.20.27]) (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 01CA4176AB9 for ; Fri, 26 Jul 2024 08:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981873; cv=none; b=vCYNFtaDwBxkpo6FmLBZInS9XsYfPeyhr0+VMQbD227JK4uSMbYDTlCgjkTmzUX/lw1ap03bWCKuK5+d4nR4zRsQlZwSyiHIh18aNFY0iQ8sHg4qqJhi0LajM0IvNTJWYhsoGoG4qnqln3MTCTKk0DiCd2Wc3tchrEF7pgDiSy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981873; c=relaxed/simple; bh=I2d1inHlPh4lMOySsiLS9Rdx4TX2rdWg6Ha+yKaNoW0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A52PgWBvoSVwh72tlaysw/PTXUnVCdQ2lWLGdALXNUNnrzihK5Dm3WuWmD5q0W0JEjlo+Rv6YxF/JHdNwktWhM3+ZCwkGWosVIDx/VsIyuau+R6a0U3X0gFqQWIANRlXl0+klF7F2KYhN/SOLqWCZYh7YqmTDmSCfMkalled4j0= 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=aOylWZoX; arc=none smtp.client-ip=47.43.20.27 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="aOylWZoX" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id XG7MsyipKvFCWXG7asRqjF; Fri, 26 Jul 2024 08:16:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721981774; bh=I2d1inHlPh4lMOySsiLS9Rdx4TX2rdWg6Ha+yKaNoW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aOylWZoX6ikBzadPcR/Fd5a332fI+zPAdE4X+pB0wlnD7Wzh16b5+cCkiwE0BL/lG rEbCCBzpfSM0A2D7kX7HFpUzqk4+h6vuEeJeeAXRBl3kL1GU8ErnY+0uLMNTZ79+Rr 1qCMo7R+A86OYzvp1vAz0IA536C2iSgjXXTcN6qRHIMA2gbkRee2HQCqmQiJwtjXSK G9mUbawp4KWgUjbuZ2MH3c6RbhyPTsZ18mdBlbWkaOH2MQPh0v4EhGsGDE66EFnDQW +RTRO0KZfPrgvTfACzAAAlVKEiOnyEoHIxmr8CWhcAZq3cUxdSh48GCAx8MaWrCimk XntG3uh/D1CjA== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=O+w/vg9W c=1 sm=1 tr=0 ts=66a35b4e 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 v2 3/5] check-non-portable-shell: loosen one-shot assignment error message Date: Fri, 26 Jul 2024 04:15:20 -0400 Message-ID: <20240726081522.28015-4-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726081522.28015-1-ericsunshine@charter.net> References: <20240722065915.80760-1-ericsunshine@charter.net> <20240726081522.28015-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: MS4xfCZ7xnSSVoddY7wDS7a9UL3rdRG1jOIJargj9BEkfqQzFXcaEqnpmVouXaKKtdw7/Jyy+032g33Ixq+rY33GJHdod8FeH2+k7388fg3Q3LptxynKITXz Wq1tOO8olzfFH8kZ52m1UrcHVfMpef28wb8iAxwCOxhmrf3gO4mRc58CdyHT9+Ac1B6tErITJQ3f4u2YudTa/gc0Z9AGKdviHV8VYHe03lrpfMK0m/gwPImq 1SMO5PusgVG7NmdFSEKD0lrr4pjW+7j2nVBgWOhEE2VEpKBynxtr3lRksVFzTVn1J+AkoZe4slZogTckJaZy42nOhWGEedsY2+2tC8XqOFdQyGl4zQal2YRO u6iqgkEz 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 considered undefined 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 "has undefined behavior according to 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 Fri Jul 26 08:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13742460 Received: from impout003.msg.chrl.nc.charter.net (impout003aa.msg.chrl.nc.charter.net [47.43.20.27]) (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 00477176AB6 for ; Fri, 26 Jul 2024 08:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981874; cv=none; b=HpA/ipsMlrpCEblLnycigAGD2lBpbCSbMfrzmBm707Nyk96I0odn3kDcnRDPEsE7s/F6ScZ7L+r3Szlw6rU+xA/o6ZTTmsMPq0DpYi3dC6PNs+Ll2Tv04RK/KJzGNx6WCLoUAxWQdLn+SjpudAZ+0saydu0PWYeQ8Qg48VvKEn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981874; c=relaxed/simple; bh=P15zAzVOaT//fKV13JnbXzzP6hN0uwUzzuuzckT4lRc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qthaiMBDEzzP3wA4hY4sf3Ft4iDIx9JOZpYJ7B6uH614HfXqgw5GFS6gNEEmISq+POdvPPSccG45p5zLAFLUp1ReW0pcT7Wi4x7gWVUyqvMCQBVzcZtPtOyQk67/ojBcNMU1U/4iQpkuuAfeau/z7Dn9wwOZHaFWew1bCc/MNUQ= 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=by47XiLD; arc=none smtp.client-ip=47.43.20.27 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="by47XiLD" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id XG7MsyipKvFCWXG7asRqjM; Fri, 26 Jul 2024 08:16:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721981774; bh=P15zAzVOaT//fKV13JnbXzzP6hN0uwUzzuuzckT4lRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=by47XiLDEiUO9gjMp+1AwVUJE8TwINTL2+VLcCgl/bAHV22WbGk2uOd7SF0LacxvK lVjagP7CFQEgTtBN6/reFAwT5+XgvDwrEc6QL3EK637rFjKV6YIvblSo8Sjz9L+QL8 sScBDrK5d90V+y9HvC3btKzsnxBWpJE7NYb6MAKj8wcjmvk064JIK+D+nRHUvVo1dQ dDdugcaRX5CZq+MRyQ1oian7otWzETm9ORzSDyjTMu6mhi9yLFK9q/JnRp5Bq7qxjw XEg3RN2Mc95dovm9lkr2ijRPlOMWqD/+6gQKSwqW51sX8R/DsgmqyR8nHiMYtCF7ja GRMbRhklOe5JA== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=O+w/vg9W c=1 sm=1 tr=0 ts=66a35b4e 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 v2 4/5] check-non-portable-shell: suggest alternative for `VAR=val shell-func` Date: Fri, 26 Jul 2024 04:15:21 -0400 Message-ID: <20240726081522.28015-5-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726081522.28015-1-ericsunshine@charter.net> References: <20240722065915.80760-1-ericsunshine@charter.net> <20240726081522.28015-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: MS4xfCZ7xnSSVoddY7wDS7a9UL3rdRG1jOIJargj9BEkfqQzFXcaEqnpmVouXaKKtdw7/Jyy+032g33Ixq+rY33GJHdod8FeH2+k7388fg3Q3LptxynKITXz Wq1tOO8olzfFH8kZ52m1UrcHVfMpef28wb8iAxwCOxhmrf3gO4mRc58CdyHT9+Ac1B6tErITJQ3f4u2YudTa/gc0Z9AGKdviHV8VYHe03lrpfMK0m/gwPImq 1SMO5PusgVG7NmdFSEKD0lrr4pjW+7j2nVBgWOhEE2VEpKBynxtr3lRksVFzTVn1J+AkoZe4slZogTckJaZy42nOhWGEedsY2+2tC8XqOFdQyGl4zQal2YRO u6iqgkEz 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 Fri Jul 26 08:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13742458 Received: from impout003.msg.chrl.nc.charter.net (impout003aa.msg.chrl.nc.charter.net [47.43.20.27]) (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 3146A176AD2 for ; Fri, 26 Jul 2024 08:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981873; cv=none; b=HveFiyTJ+4ozPQJJVIGyttrHULYtatwfwTHZ5hdF+GjzQdBv4ADWww8MBTjWasSkvQnK4mPN+5GzAuLCvSl810OSas+HwHIGkyRfxuZhVhGfYQFH2zwjAhMnhE4KH2MNsepawbKjbC1ALoR/Gm8UffBOZ9QLq30MjWQmz3RAH9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721981873; c=relaxed/simple; bh=HSWVSVXP5Aayj4xTZ/KNVNu1zUcDbtAUSlxyJTXdOrc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DHO5EpXqcAaN+gfDmabgGnWI/c8jAKc8aJrYfbq0jZWaxMP/8NdCMM8sp90Y8lyOwViyJTBoEzKQqCUTm4jsZmvCdSIF9V0MPwGh4atfNqB+CGAw7DGKnqxOOGSSpm054MhMUTdb9AaNEA/DRPcipTIaZD5QIu+3Ci3FiCw3CJs= 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=CIGajTGK; arc=none smtp.client-ip=47.43.20.27 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="CIGajTGK" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id XG7MsyipKvFCWXG7asRqjU; Fri, 26 Jul 2024 08:16:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721981775; bh=HSWVSVXP5Aayj4xTZ/KNVNu1zUcDbtAUSlxyJTXdOrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CIGajTGKoH6PXay7L8MZzvl9T4ycCQWX6Tt6nDUwcww4g7epf3S/5093EVjwKml88 BAFqv+9h7K7tHEpYNWnfl1TL5tidHltQDcXcJ2uco+QgVw90UG8UmvJXhCoaIr5Xzr m/Yc08kckwfvNdIKxvP2B0EszKnrsy6v0MmO5tp1xrCWIwfUscbLvDDUKNhdME1Hy0 vktPkYXyX7wX9tjrgFsx7Ey2B3RQMiku6ovSZoKDD/Mu9KCdXVp8xEQ8BYHmp67Oh5 5ZGtVLC2oc6WN2JwKoHOrsWnUApKa6HyQDMen+OrdLldqJUtmdsFTQnBcRIX36v9Kn bBNWnAxLUbkrA== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=O+w/vg9W c=1 sm=1 tr=0 ts=66a35b4f 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 v2 5/5] check-non-portable-shell: improve `VAR=val shell-func` detection Date: Fri, 26 Jul 2024 04:15:22 -0400 Message-ID: <20240726081522.28015-6-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726081522.28015-1-ericsunshine@charter.net> References: <20240722065915.80760-1-ericsunshine@charter.net> <20240726081522.28015-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: MS4xfPNck9Qxa8Ggr0rV0YfW5ng01ffcJYtUzWB2fM8y0Ei3sxilqrpdeQo+D94zMv0kyICJ0t4wZt7dBls3M002GlhRPnjlLxcB5s9jZiWtsLrRRzWm1Xau fnOK+DDZhSP/c5fCTPM3eZEgAwgpdgIczYu9MHI+sQ2JXZuQO9WKsj5lyKs5wLkuj426LsFmOTgksLN6G7S/N/clG6oFRzTPQrJyqokEL71rQwUdSYEvAI/P v/LLZvvODgG76dzzNZh2IljbTOqmeWkbxbhT3I4RQpvpnQp/60oIhgm4KCb60dQihUFRhYI0dfGg1nQOTti9sYWvIb33SUesWuUyZorZo94Yrn/pGxKwyDfw zdzZA/on From: Eric Sunshine The behavior of a one-shot environment variable assignment of the form "VAR=val cmd" is undefined 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