From patchwork Mon Jul 22 06:59:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13738429 Received: from impout008.msg.chrl.nc.charter.net (impout008aa.msg.chrl.nc.charter.net [47.43.20.32]) (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 361741BC3F for ; Mon, 22 Jul 2024 07:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721631694; cv=none; b=d2Fsx7eOqLUo7nBv4c5hSBLvNN9+OAKIl9SynKVhioSPfWoSi1LB+lPswGI+nFh+Hva9JWpQLgUjw6pHFUDa1cNh0k9Xs9VxUBIKmvAktGxVDc8irm/n4a+SRcU9mTMyqkLP6TPDFW0AgCtCyVi2eoxIk3yQNxXEvLr0sCay658= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721631694; c=relaxed/simple; bh=QLeeY7EoYlJ+Ru+Ng+lPV7m07XU9llrKuAXizF1uq1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YOjqa3B6pRPqM32twrXEecfKWt83bNpecOBeJj0B8Z6hTxNUsFFuM/12r2fNFzvNXaoZ4Bs44FmY7xgSwelQMjS2x94Yoc0hsCprXJ4jnV4AQn3QI9zfeIh31NjE4qeOZGq32gca5/GcScDMglcDon76dd7memUHhMU+nNYBCSw= 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=Vvddad8y; arc=none smtp.client-ip=47.43.20.32 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="Vvddad8y" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Vn1PsPWKO6kyQVn1WsyVio; Mon, 22 Jul 2024 06:59:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721631594; bh=QLeeY7EoYlJ+Ru+Ng+lPV7m07XU9llrKuAXizF1uq1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Vvddad8yNaWSZbYf3mXZgoK98Ctr8BBHuDuP0UbyVJwVJ4Kv51eHGpdOACy4f0GNx i4D/QDUVG0ACTYohWSeHgyuMAF28sd88QDS8UTgc+iIruinSRS9v6gnAuYOlGSc/gl gxBcg6CIpIpUx36GwYikh7P+x47FOpZ/a441JSZA3jEnflcKVPc2QL4bth0oh9y5Gx 83tpfeeazp4Q7hGiW6pz138KQWQsmNCx7QWC9aXI+9Ez7BP4zz1gjIHIvg6TVRgZqv oQAqLl+g3gbBDqXrThfWZJahVkXEAEubxFdu5PEXNW5U0/s2ko7sR1DNM5keDlDQKa RGuyRL8pXALCQ== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=bKkQIu+Z c=1 sm=1 tr=0 ts=669e036a a=4h87Vkt5vDwEBqoyvSX4iA==:117 a=4h87Vkt5vDwEBqoyvSX4iA==:17 a=BCjA09oAAAAA:8 a=A1X0JdhQAAAA:8 a=XRQI_hbnlHMHZBUsm7oA: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?= , Eric Sunshine Subject: [PATCH 1/4] t3430: modernize one-shot "VAR=val shell-func" invocation Date: Mon, 22 Jul 2024 02:59:11 -0400 Message-ID: <20240722065915.80760-2-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240722065915.80760-1-ericsunshine@charter.net> References: <20240722065915.80760-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: MS4xfJwrnF6cpF/Rj557ejoMhU3bvAdfl2R/9zhDR144l0NPN+KmCnUzHiSChEn4t0dN53xbwtB/u65B3HDOV00PYLAzWb8E9tD43W89Ckd4FZAmBdjNwvUx ZORQyFKFOpNWxtLLd304N6e2JJ+LFu+Xu3vRZRzZi5zuvKEZS5AI72Zzi4HUhDXZVT2ujYDJs2BtZlOGcz9rpl0zre15nwkdsr1uBEbgM3PdLyCULfcPiYl3 8eQLNqYicB/YKdMcOOVl6Q2bsksSJbCoNtY69GcgEtvuDAqNDYFMsvltMgiAwDTT From: Eric Sunshine Unlike "VAR=val cmd" one-shot environment variable assignments which exist only for the invocation of 'cmd', those assigned by "VAR=val shell-func" exist within the running shell and continue to do so until the process exits (or are explicitly unset). check-non-portable-shell.pl warns when it detects such usage since, more often than not, the author who writes such an invocation is unaware of the undesirable behavior. A common way to work around the problem is to wrap a subshell around the variable assignments and function call, thus ensuring that the assignments are short-lived. However, these days, a more ergonomic approach is to employ test_env() which is tailor-made for this specific use-case. Signed-off-by: Eric Sunshine --- t/t3430-rebase-merges.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 36ca126bcd..e851ede4f9 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -392,8 +392,8 @@ 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_env GIT_AUTHOR_NAME="Parsnip" GIT_AUTHOR_EMAIL="root@example.com" \ + test_commit second-root && test_commit third-root && cat >script-from-scratch <<-\EOF && pick third-root From patchwork Mon Jul 22 06:59:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13738425 Received: from impout008.msg.chrl.nc.charter.net (impout008aa.msg.chrl.nc.charter.net [47.43.20.32]) (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 3613F1BC3C for ; Mon, 22 Jul 2024 07:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721631693; cv=none; b=sTBOLI7+zkHXFnx10DuS+nSmkcSmTy4oHDyuAKEKfWHSubeLU1rwiABtF630ROdXTpajk5VB5Q49972KQ/J6u40bSoUe6LUeXMCAjYhCh0tpiPC1WxUc6TEQP4HTSWFAJ9c4RDXAZCuQW7AZdd4aZYFJqh4iFh8p3jJN1OM6H3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721631693; c=relaxed/simple; bh=9hui7ZJ3B0mbh/Zlqagvhp9c3aTthchduINltJ1Sht0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aDXohG/xYc4UsDUYuJ7G4mN71LVoLyG9oL0LrvhXiF/Y1HV40TRPH8YZw5g0U5MshSYbU3VpKKvam6jF7P8QRuPO0/BF4bnIjwUj9xYCr5AHDUoLLHx5fLgAwGll4hT+TTx3WP0bXUBs+7bvdW0vvbQhhRciYGZijdBYFKbuJAA= 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=qPmAn0Ri; arc=none smtp.client-ip=47.43.20.32 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="qPmAn0Ri" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Vn1PsPWKO6kyQVn1WsyViu; Mon, 22 Jul 2024 06:59:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721631594; bh=9hui7ZJ3B0mbh/Zlqagvhp9c3aTthchduINltJ1Sht0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qPmAn0RiD55c6ZHd7bm3QxoS3wRavPCNp6jb8y0v5GMsGyR9Nh+qEPrVK560RZQ6W VQc444qSgAUx1UawAdGu0z7X4EE5StcuVTX39NP7IEZh2NUeSRRKusOi5L1B19X+ym u3XaC8xIMmj9jpDrdsgeWdxVOMEznjTjS6l2oRMUkEweP5B7Fob5575y4G5jGmvRnH cDb9vjsG6sqKJLqaPgjlmoDT+VlczxVa0XoRpLKpTXkrUqV8eQSka6OBwDJ7wILOrY Ua9FXFboLUvBQRi/Hh07LUK3Z/OLsMFTX9FToLsYtHTIhLxRLsDTnt2jkBtNqkM16x mTYHHRDsRK9UQ== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=bKkQIu+Z c=1 sm=1 tr=0 ts=669e036a a=4h87Vkt5vDwEBqoyvSX4iA==:117 a=4h87Vkt5vDwEBqoyvSX4iA==:17 a=BCjA09oAAAAA:8 a=iqTJSk_ugSLm26MjKVEA:9 a=rRh7KEUCiO8A:10 a=jYKBPJSq9nmHKCndOPe9:22 From: Eric Sunshine To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Rub=C3=A9n_Justo?= , Eric Sunshine Subject: [PATCH 2/4] t4034: fix use of one-shot variable assignment with shell function Date: Mon, 22 Jul 2024 02:59:12 -0400 Message-ID: <20240722065915.80760-3-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240722065915.80760-1-ericsunshine@charter.net> References: <20240722065915.80760-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: MS4xfJwrnF6cpF/Rj557ejoMhU3bvAdfl2R/9zhDR144l0NPN+KmCnUzHiSChEn4t0dN53xbwtB/u65B3HDOV00PYLAzWb8E9tD43W89Ckd4FZAmBdjNwvUx ZORQyFKFOpNWxtLLd304N6e2JJ+LFu+Xu3vRZRzZi5zuvKEZS5AI72Zzi4HUhDXZVT2ujYDJs2BtZlOGcz9rpl0zre15nwkdsr1uBEbgM3PdLyCULfcPiYl3 8eQLNqYicB/YKdMcOOVl6Q2bsksSJbCoNtY69GcgEtvuDAqNDYFMsvltMgiAwDTT From: Eric Sunshine Unlike "VAR=val cmd" one-shot environment variable assignments which exist only for the invocation of 'cmd', those assigned by "VAR=val shell-func" exist within the running shell and continue to do so until the process exits (or are explicitly unset). In most cases, it is unlikely that this behavior was intended by the test author, and, even if those leaked assignments do not impact other tests today, they can negatively impact tests added later by authors unaware that the variable assignments are still hanging around. Address this shortcoming by ensuring that the assignments are short-lived. 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 Mon Jul 22 06:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13738427 Received: from impout008.msg.chrl.nc.charter.net (impout008aa.msg.chrl.nc.charter.net [47.43.20.32]) (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 1F9AF79F5 for ; Mon, 22 Jul 2024 07:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721631693; cv=none; b=k1k/p+2aa09Lxf+XnUmrZtoovezD2+5v0NkjEOV+Gw2kA/9Ba4mJ2wpkMfVtkjtvLKU1haY9DoPI+BYYpiR+U7agpfawvHKhr+edzwR7aqLg5T4gM40pZh9QPVCLjt/0hSBdDm1Aiodlqh2kgHBAu4rC6eFvkXsKQ7KgZvmY348= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721631693; c=relaxed/simple; bh=rQCs9qzUuPPDjweHat98e/6punUwV6cE3F1lasJp11Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DH5I0ttkyKEyF3/1hAm68rvxngbmHM5DXuRd9YzD12o0gvjhb8Tt/j8VWR4IeKxm8LWhvuUhI9Iqy74XT4OXFWYwPwtZSZRrSUMf4T7QYGrGCaJUuaPDUNlEa6SAEMUtv5Rj4RO2jZyIfdLfpTyg9F2ZAvSxMDDk2mTjcYqGLsg= 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=GKd4a9lw; arc=none smtp.client-ip=47.43.20.32 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="GKd4a9lw" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Vn1PsPWKO6kyQVn1WsyViy; Mon, 22 Jul 2024 06:59:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721631595; bh=rQCs9qzUuPPDjweHat98e/6punUwV6cE3F1lasJp11Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GKd4a9lwvhUKZzXMTb4nxISpnn3qa1u5RfZ2Ymdixg8frZ1/R3unC9tPDGVkFqON9 +c3E8sON+dhpSbfJgxoA82Z8PKVnZE/rTpG4js+cnCYeIN5Bdv4VNCMTqTUcnxlnZV Lzgrv7Pj604Ctn1NksngSUs4ovvKwdgYSRE29UmlKpfFOTcZwyghGM2UoFLm9LVR5I BlcWf7caG64C2fjwcA4wnkczuRa95tbinhimSBghjDnced+6WzvbwDubx7ks0tNFYW pIPOArWybcyGuhd8vTDyNzDEPK3PGb1t35UO1ot7MJ0kAEKLLeZOIZdW1WU/JJNbHB dg3DLTYwf6g+Q== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=bKkQIu+Z c=1 sm=1 tr=0 ts=669e036b 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?= , Eric Sunshine Subject: [PATCH 3/4] check-non-portable-shell: improve `VAR=val shell-func` detection Date: Mon, 22 Jul 2024 02:59:13 -0400 Message-ID: <20240722065915.80760-4-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240722065915.80760-1-ericsunshine@charter.net> References: <20240722065915.80760-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: MS4xfK654EkRlGYxjL4b4/f9qU7qg3N5wjZgQCRwYOJj9qrcE9pNr1nbK5o4tYl8jmyESG+69SiDIEMoA6etlxcjc71CJPFs5qgCcN+eyhMayf8MR3e4xeej ODYLJ0OxuaSfjrHPGFEXqnjOe7PGuGe3FxHQTWeina6rfqAuLn4Tv1y6wy/LU/rEkmXY3MiWbQsrcr1HhRZ4BZyC0E95TvREh+RtOrdmPY47yKPHwtXjTbjk vDLO0s1BgfdCPqytbC/vmKlrV89XkAYq7R/dXoXIdyBSV3UwiFoWF75w1GZbHMNZ From: Eric Sunshine Unlike "VAR=val cmd" one-shot environment variable assignments which exist only for the invocation of 'cmd', those assigned by "VAR=val shell-func" exist within the running shell and continue to do so until the process exits. check-non-portable-shell.pl warns when it detects such usage since, more often than not, the author who writes such an invocation is unaware of the undesirable behavior. 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 b2b28c2ced..44b23d6ddd 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" assignment extends beyond "shell_func"'; $line = ''; # this resets our $. for each file From patchwork Mon Jul 22 06:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13738428 Received: from impout008.msg.chrl.nc.charter.net (impout008aa.msg.chrl.nc.charter.net [47.43.20.32]) (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 1F9D38F58 for ; Mon, 22 Jul 2024 07:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.43.20.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721631694; cv=none; b=CGcDotind0TpOGFPAIIhlMn9UaHSNoR9IRnKphR1/OgKSeHlTCycbHgSsCyIKiKE03id1IuCKn8kDAZ59AnoK3FkQbPZgkBRNHReYEYBpAs8c4TrwdygEoW9xzGOMtXjPqlkrukbgkyeQ4nfdoibSKI5vwNv18aAJR1fyHXZ2B4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721631694; c=relaxed/simple; bh=azRrAol6oY2ZqA8UUK0XHRfn0bab1pszd8eEBOwppeY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=taLFbQ9TYi9ngZdhNnN8YuhIKCpulqGe7W9m+/dGL2f99RqyqEvHW2edZhyJtbxEQmpF7ck5zxjR5xCfYDw3MSyVTDY95kWXVsh3BjSRNDXqwvFN5RvzY2Ot/de2ypiJusaz0yPIBDr6KlDfh5CCAhjNN2RgYpJUzOdAAIkIo10= 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=VfvMO/lx; arc=none smtp.client-ip=47.43.20.32 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="VfvMO/lx" Received: from localhost.localdomain ([97.71.114.58]) by cmsmtp with ESMTPA id Vn1PsPWKO6kyQVn1XsyVj4; Mon, 22 Jul 2024 06:59:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charter.net; s=c20240129; t=1721631595; bh=azRrAol6oY2ZqA8UUK0XHRfn0bab1pszd8eEBOwppeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VfvMO/lxx6vdD99IKk2nbqJL0Eazm3EIZkfdeE8ld7tgbG+q4Yelc5LaW8aZtwCnu hqBVp6JE8sOFm5UW1xYWRbueGA3ioI036H91x+vlfn7q5sgqsgfq3upc8uD/NRFkA7 rOCjgipRaW9B2XbxbcTG2SN5J6b9aKWRBm2X2ke2q7prsDpNlxuUSfqDMEl4gNYvY4 6yb+dcMGnF8T8uZGiSClx6hK8YMe0kkv+RFMGftbBhEXkfJcFH0j+13h38b21R7zLU mQraNGSpALDQqXVJXIzsHCow7H1+husgXnWqNW0KP79o+dSdKyF1rFDXKxtDIRhQ0o uXJut/bnzY5Kg== Authentication-Results: charter.net; auth=pass (LOGIN) smtp.auth=ericsunshine@charter.net X-Authority-Analysis: v=2.4 cv=bKkQIu+Z c=1 sm=1 tr=0 ts=669e036b 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?= , Eric Sunshine Subject: [PATCH 4/4] check-non-portable-shell: suggest alternative for `VAR=val shell-func` Date: Mon, 22 Jul 2024 02:59:14 -0400 Message-ID: <20240722065915.80760-5-ericsunshine@charter.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240722065915.80760-1-ericsunshine@charter.net> References: <20240722065915.80760-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: MS4xfK654EkRlGYxjL4b4/f9qU7qg3N5wjZgQCRwYOJj9qrcE9pNr1nbK5o4tYl8jmyESG+69SiDIEMoA6etlxcjc71CJPFs5qgCcN+eyhMayf8MR3e4xeej ODYLJ0OxuaSfjrHPGFEXqnjOe7PGuGe3FxHQTWeina6rfqAuLn4Tv1y6wy/LU/rEkmXY3MiWbQsrcr1HhRZ4BZyC0E95TvREh+RtOrdmPY47yKPHwtXjTbjk vDLO0s1BgfdCPqytbC/vmKlrV89XkAYq7R/dXoXIdyBSV3UwiFoWF75w1GZbHMNZ 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 44b23d6ddd..56db7cc6ed 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'); /\b([A-Z0-9_]+=(\w*|(["']).*?\3)\s+)+(\w+)/ and !/test_env.+=/ and exists($func{$4}) and - err '"FOO=bar shell_func" assignment extends beyond "shell_func"'; + err '"FOO=bar shell_func" assignment extends beyond "shell_func" (use test_env FOO=bar shell_func)'; $line = ''; # this resets our $. for each file close ARGV if eof;