From patchwork Sat Apr 6 00:08:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13619603 Received: from pb-smtp1.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) (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 B1D4B620 for ; Sat, 6 Apr 2024 00:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.108.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362149; cv=none; b=jWuoMuYUzIN1D7BNareMMa0Ch+4oRAnfjPLpiXNjzFb1rMfpBrxBYo2rmMJQN2TQqg8EXz7JSsi1tDUXbVrIBMf4W2QToiq9kJl5p57dEhIXs0HSW3afWYy+h9cuqOCLEGag46dbF81QeQgNMJnExGnRjwIbadn7vCjfQNcOxso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362149; c=relaxed/simple; bh=YcyrWznCN6p/ZcnltNRumLFkOuX8uQB8Wjy2nan2rHY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mgq3xPo/L5f0TBFmJgA6fVkU0Wh7JyeboPG83c0LOHyQTuIcSgvhEriTIDKntmGOw8fP3M1lazsEaWHo7fry0eke12Q0LGzwPE/dwEzycfsLZhFVVEwwXtFBg3YIUltfEkDhvvT+rgDhbrZPi9ZJscRj+gVPKp/B7rsPfWfgUlE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=CCwVsunk; arc=none smtp.client-ip=64.147.108.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="CCwVsunk" Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id A5D7B1F28B4; Fri, 5 Apr 2024 20:09:06 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=YcyrWznCN6p/ZcnltNRumLFkO uX8uQB8Wjy2nan2rHY=; b=CCwVsunkSzpLvspEoh/wAixxMI/RkqJrAG+65db6y Gb5iap1aEUetnzNPyovl7fW9vViT4nXStlgvDWdgNXYzN4qBxKDFQM9hslAnxCaj 2WZN4CmrGPVWptllwi50HBeP9tcP/XSAIUHDquElKjJbMsNtwVh0rX6Z5phMtOQN QU= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 9D2031F28B3; Fri, 5 Apr 2024 20:09:06 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.125.229.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id E955D1F28B2; Fri, 5 Apr 2024 20:09:05 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 1/6] CodingGuidelines: describe "export VAR=VAL" rule Date: Fri, 5 Apr 2024 17:08:57 -0700 Message-ID: <20240406000902.3082301-2-gitster@pobox.com> X-Mailer: git-send-email 2.44.0-501-g19981daefd In-Reply-To: <20240406000902.3082301-1-gitster@pobox.com> References: <20240406000902.3082301-1-gitster@pobox.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: E1E10AD6-F3A9-11EE-BAC5-78DCEB2EC81B-77302942!pb-smtp1.pobox.com https://lore.kernel.org/git/201307081121.22769.tboegi@web.de/ resulted in 9968ffff (test-lint: detect 'export FOO=bar', 2013-07-08) to add a rule to t/check-non-portable-shell.pl script to reject export VAR=VAL and suggest us to instead write it as "export VAR" followed by "VAR=VAL". This however was not spelled out in the CodingGuidelines document. We may want to re-evaluate the rule since it is from ages ago, but for now, let's make the written rule and what the automation enforces consistent. Signed-off-by: Junio C Hamano --- Documentation/CodingGuidelines | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 9495df835d..0a39205c48 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -188,6 +188,12 @@ For shell scripts specifically (not exhaustive): hopefully nobody starts using "local" before they are reimplemented in C ;-) + - Some versions of shell do not understand "export variable=value", + so we write "export variable" and "variable=value" on separae + lines. Note that this was reported in 2013 and the situation might + have changed since then. We'd need to re-evaluate this rule, + together with the rule in t/check-non-portable-shell.pl script. + - Use octal escape sequences (e.g. "\302\242"), not hexadecimal (e.g. "\xc2\xa2") in printf format strings, since hexadecimal escape sequences are not portable. From patchwork Sat Apr 6 00:08:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13619605 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) (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 39EF280B for ; Sat, 6 Apr 2024 00:09:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.108.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362156; cv=none; b=mpVpW8KOhTSHuH8ZkKdnzKmMbqEF3QnjGGCSS7P0S0T3iRHD2jx2ufPAwU87mQI6AQEkm4kS956EfESD2YhOUS1BkSkb1Su0/9v/C622iYeOqOEtypAdix1BU3yaHK8OEcTvi1228sn6FbiN9WEGmOSl+O1Q4dGhdEnmXntxhoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362156; c=relaxed/simple; bh=blVXfTqdy12j+HTgGtXpARBq/hyGX0LThU5hHImfJgE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gPDVDaLiKoD4IY6I58hpDq/tFNS4wUJ03x3dREZOor2XpPR9XfCh3vy5RS2g/V/cBUoygneNCJDZwjmHZrDsq+EvN31UdY/R9QzuwzyepmDIay1HsWfSUpQpNqmK+WWrHLi2iiJRW9HfBPLE/szAt8YqoeWmf5FY1AdUYhpqJoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=boq6d2Hf; arc=none smtp.client-ip=64.147.108.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="boq6d2Hf" Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 58A9B1DB1F9; Fri, 5 Apr 2024 20:09:08 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=blVXfTqdy12j+HTgGtXpARBq/ hyGX0LThU5hHImfJgE=; b=boq6d2Hfz7JIe40jiVlLONPLsrXNtdVUbK5DU546c vDYpJDvX+YYrp+iSdCEfQuK0OACCUxQlsCHZvzrfs5Q7jo/RNIB9S8hByWIWQyDQ K5qvels2wBve0dTWkAB/WR+5WeFZUP1pd3s6QxXQfvIgjpwBCDyvJSbNQmk7fLII 1A= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4F4C71DB1F8; Fri, 5 Apr 2024 20:09:08 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.125.229.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id AD9541DB1F6; Fri, 5 Apr 2024 20:09:07 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 2/6] CodingGuidelines: quote assigned value in 'local var=$val' Date: Fri, 5 Apr 2024 17:08:58 -0700 Message-ID: <20240406000902.3082301-3-gitster@pobox.com> X-Mailer: git-send-email 2.44.0-501-g19981daefd In-Reply-To: <20240406000902.3082301-1-gitster@pobox.com> References: <20240406000902.3082301-1-gitster@pobox.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: E2ED2AE0-F3A9-11EE-9479-25B3960A682E-77302942!pb-smtp2.pobox.com Dash bug https://bugs.launchpad.net/ubuntu/+source/dash/+bug/139097 lets the shell erroneously perform field splitting on the expansion of a command substitution during declaration of a local or an extern variable. The explanation was stolen from ebee5580 (parallel-checkout: avoid dash local bug in tests, 2021-06-06). Signed-off-by: Junio C Hamano --- Documentation/CodingGuidelines | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 0a39205c48..1cb77a871b 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -194,6 +194,20 @@ For shell scripts specifically (not exhaustive): have changed since then. We'd need to re-evaluate this rule, together with the rule in t/check-non-portable-shell.pl script. + - Some versions of dash have broken variable assignment when prefixed + with "local", "export", and "readonly", in that the value to be + assigned goes through field splitting at $IFS unless quoted. + + DO NOT write: + + local variable=$value ;# wrong + local variable=$(command args) ;# wrong + + and instead write: + + local variable="$value" + local variable="$(command args)" + - Use octal escape sequences (e.g. "\302\242"), not hexadecimal (e.g. "\xc2\xa2") in printf format strings, since hexadecimal escape sequences are not portable. From patchwork Sat Apr 6 00:08:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13619604 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) (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 92047363 for ; Sat, 6 Apr 2024 00:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.228.157.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362155; cv=none; b=LxYhiLzKG4TwbyJ+JGBfpUS/II0+whE6lrhVWivNngHYUyNnf0vgQryDIhbe8R0UNf74XNkhJz02CR0QgZZBL4JgCmzBDh4w2VEXo1OjdwHpZWi8w+bizsnnd6sFtHb/QYxZ51nbyT+8WGAsceAYD5aIDPaKbyEsAtLhrnF5tk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362155; c=relaxed/simple; bh=2ijkC/L/hBTaJWxb5FRrEyXVxCsUmkWN+/1HcypBIQ4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c0Ez9rMq1gpc6QS+tiVkAlJd+FlsCz6MozF7M4BtK+dXC0J2C+j4ssNH71esY0MfRIy+WzPJWTMaF/xBE10VTmdhPnoOT/ualowHXxxB/gF/M6t5W4zwI6c1Zhd9ls0OEmbW1v7e2yt+ly/+T/zw/2sEUoXlWCtWQzIgwahBQb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=nqPn/4cT; arc=none smtp.client-ip=173.228.157.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="nqPn/4cT" Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 279FE27C39; Fri, 5 Apr 2024 20:09:13 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=2ijkC/L/hBTaJWxb5FRrEyXVx CsUmkWN+/1HcypBIQ4=; b=nqPn/4cTKrqpGVT9uYYq9Iiotp1oam/GLAQlhWs3K 83nEHVxtrA2J5zELAAKDb982OJhjGWiKejWyAe4xySFodAtQo67TgpZsajOLpPna bGuWPnRe54NCokVwJ3Xv+LFrw5AWdsm/HUifjUg3ndptkzBOEcqEkYwuVkIPrC+I CY= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 2042F27C38; Fri, 5 Apr 2024 20:09:13 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.125.229.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id A5EA927C37; Fri, 5 Apr 2024 20:09:09 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 3/6] t: local VAR="VAL" (quote positional parameters) Date: Fri, 5 Apr 2024 17:08:59 -0700 Message-ID: <20240406000902.3082301-4-gitster@pobox.com> X-Mailer: git-send-email 2.44.0-501-g19981daefd In-Reply-To: <20240406000902.3082301-1-gitster@pobox.com> References: <20240406000902.3082301-1-gitster@pobox.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: E4193080-F3A9-11EE-B1B9-F515D2CDFF5E-77302942!pb-smtp20.pobox.com Future-proof test scripts that do local VAR=VAL without quoting VAL (which is OK in POSIX but broken in some shells) that is a positional parameter, e.g. $4. Signed-off-by: Junio C Hamano --- t/lib-parallel-checkout.sh | 2 +- t/t2400-worktree-add.sh | 2 +- t/t4210-log-i18n.sh | 4 ++-- t/test-lib-functions.sh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/t/lib-parallel-checkout.sh b/t/lib-parallel-checkout.sh index acaee9cbb6..8324d6c96d 100644 --- a/t/lib-parallel-checkout.sh +++ b/t/lib-parallel-checkout.sh @@ -20,7 +20,7 @@ test_checkout_workers () { BUG "too few arguments to test_checkout_workers" fi && - local expected_workers=$1 && + local expected_workers="$1" && shift && local trace_file=trace-test-checkout-workers && diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index 051363acbb..5851e07290 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -404,7 +404,7 @@ test_expect_success '"add" worktree with orphan branch, lock, and reason' ' # Note: Quoted arguments containing spaces are not supported. test_wt_add_orphan_hint () { local context="$1" && - local use_branch=$2 && + local use_branch="$2" && shift 2 && local opts="$*" && test_expect_success "'worktree add' show orphan hint in bad/orphan HEAD w/ $context" ' diff --git a/t/t4210-log-i18n.sh b/t/t4210-log-i18n.sh index d2dfcf164e..75216f19ce 100755 --- a/t/t4210-log-i18n.sh +++ b/t/t4210-log-i18n.sh @@ -64,7 +64,7 @@ test_expect_success 'log --grep does not find non-reencoded values (latin1)' ' ' triggers_undefined_behaviour () { - local engine=$1 + local engine="$1" case $engine in fixed) @@ -85,7 +85,7 @@ triggers_undefined_behaviour () { } mismatched_git_log () { - local pattern=$1 + local pattern="$1" LC_ALL=$is_IS_locale git log --encoding=ISO-8859-1 --format=%s \ --grep=$pattern diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 2f8868caa1..3204afbafb 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1689,7 +1689,7 @@ test_parse_ls_tree_oids () { # Choose a port number based on the test script's number and store it in # the given variable name, unless that variable already contains a number. test_set_port () { - local var=$1 port + local var="$1" port if test $# -ne 1 || test -z "$var" then From patchwork Sat Apr 6 00:09:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13619606 Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) (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 4C2893C0B for ; Sat, 6 Apr 2024 00:09:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.228.157.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362158; cv=none; b=U5hokfrV1+bBbzwX3Guy+X1x4z3UpeJg5CgXE66K6w24tyQmuh1RXzmhx2ovxpeVAT+ISjWq6/qkgHIDunphCs+f3ms7syJ8lzzpCAmb0Qq3utvJ2ZrIhQEshrZMngXSCu84FICJhMTrFDVBlcR0pgYS4+E+IClXHABRB704xhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362158; c=relaxed/simple; bh=ApeOdrvDzYLcZ9/Qa9hRh/CgFwQN9rflZ7kbYOdPR/o=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s8v43hhiW/14Cf1xmN1YVrxrC3CKAjqi/cgoSUEidq85IcYLXzgJYkJ7Y5tSTkWixcQq0DO9nUrmhNq23+s76sMxdnSuhgvB2siaH3JCL62FBfUZQTCTYUtOErrpPqnli3jdE6zrI3RvJZwkLX7Gpv4lpg5WjCDIwGeKano85S4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=TwFksmGh; arc=none smtp.client-ip=173.228.157.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="TwFksmGh" Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id E42FF24028; Fri, 5 Apr 2024 20:09:16 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=ApeOdrvDzYLcZ9/Qa9hRh/CgF wQN9rflZ7kbYOdPR/o=; b=TwFksmGhfzrs3CstyGqw8ujAnih3+IfIhP3gZlHt9 cOLyLTJjXFwCmkXX0GQJFj6i2urIEPdUhwlR4lMNSfGgQ0oTFf0Wd8dTo+/iKfj4 +RLi5GPFGDpoClIGz1ntu660CaVT+pqk/Et7AM8pYojr64uyaQ+f/Q+BNJ9k3mND dw= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id DE2C024027; Fri, 5 Apr 2024 20:09:16 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.125.229.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 6ADD424025; Fri, 5 Apr 2024 20:09:13 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 4/6] t: local VAR="VAL" (quote command substitution) Date: Fri, 5 Apr 2024 17:09:00 -0700 Message-ID: <20240406000902.3082301-5-gitster@pobox.com> X-Mailer: git-send-email 2.44.0-501-g19981daefd In-Reply-To: <20240406000902.3082301-1-gitster@pobox.com> References: <20240406000902.3082301-1-gitster@pobox.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: E6569CC0-F3A9-11EE-8058-A19503B9AAD1-77302942!pb-smtp21.pobox.com Future-proof test scripts that do local VAR=VAL without quoting VAL (which is OK in POSIX but broken in some shells) that is a $(command substitution). Signed-off-by: Junio C Hamano --- t/t4011-diff-symlink.sh | 4 ++-- t/test-lib-functions.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index d7a5f7ae78..bc8ba88719 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -13,13 +13,13 @@ TEST_PASSES_SANITIZE_LEAK=true # Print the short OID of a symlink with the given name. symlink_oid () { - local oid=$(printf "%s" "$1" | git hash-object --stdin) && + local oid="$(printf "%s" "$1" | git hash-object --stdin)" && git rev-parse --short "$oid" } # Print the short OID of the given file. short_oid () { - local oid=$(git hash-object "$1") && + local oid="$(git hash-object "$1")" && git rev-parse --short "$oid" } diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 3204afbafb..3dc638f7dc 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1764,7 +1764,7 @@ test_subcommand () { shift fi - local expr=$(printf '"%s",' "$@") + local expr="$(printf '"%s",' "$@")" expr="${expr%,}" if test -n "$negate" From patchwork Sat Apr 6 00:09:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13619607 Received: from pb-smtp1.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) (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 4D81E848D for ; Sat, 6 Apr 2024 00:09:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.108.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362159; cv=none; b=aCAwDyTzZSZRw4EjDemPW9ySawW9Yi/+vAbmgQZ225ngKsMZc3jLs0Sm+/rnJxeNhZH5BTKKNfEjKONtSnuFpn0N1y59XjbIACM2Z5YAkNrOgZnLkfPn0819d8iGKPb5D2vrvWjvG7zEAsxMrntR0szE3rdL0QeYG/HwcVc9Hwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362159; c=relaxed/simple; bh=wNOneWXNqWWmQK5R3agwgQwZ5GX0ELcvqgXnIR3/Jpc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U/g2pSOmLXy6rHPMPjPTQFdrkzYBnGCKHCAtYoMfC0QUTUcP/mqff4BP5zHA1Brg5hBZwbm6Yj64z4da5QJdhW8E054GMgIbGw54B67ZEzzPLjRdIj1cJzEXqtuo84ndgzAF9si4qY8J8pjyPDtJgAr7bsLw3FlfHIkDOVsCpFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=KeFLo0ox; arc=none smtp.client-ip=64.147.108.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="KeFLo0ox" Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 7E7151F28BE; Fri, 5 Apr 2024 20:09:17 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=wNOneWXNqWWmQK5R3agwgQwZ5 GX0ELcvqgXnIR3/Jpc=; b=KeFLo0oxt8a2rG1yfNLjFG832pX8iGfNj9fgMQfCo 3XCPdIV2gVTlJpvcIIKEIBLd7aPn4AQYD6e13wr97lGL5HQ/b2z4t0UZYrIuHoQf HLsFqEWWA8TaCfFqK+PuX7W0C22vJT0kkxGtkP1MxVelJNETxZRj5sIC2pCh5Wz1 6E= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 765D11F28BD; Fri, 5 Apr 2024 20:09:17 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.125.229.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id DDB9B1F28BC; Fri, 5 Apr 2024 20:09:16 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 5/6] t: local VAR="VAL" (quote ${magic-reference}) Date: Fri, 5 Apr 2024 17:09:01 -0700 Message-ID: <20240406000902.3082301-6-gitster@pobox.com> X-Mailer: git-send-email 2.44.0-501-g19981daefd In-Reply-To: <20240406000902.3082301-1-gitster@pobox.com> References: <20240406000902.3082301-1-gitster@pobox.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: E8681458-F3A9-11EE-ADF8-78DCEB2EC81B-77302942!pb-smtp1.pobox.com Future-proof test scripts that do local VAR=VAL without quoting VAL (which is OK in POSIX but broken in some shells) that is ${magic-"reference to a parameter"}. Signed-off-by: Junio C Hamano --- t/test-lib-functions.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 3dc638f7dc..029cb31ffe 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -330,7 +330,7 @@ test_commit () { shift done && indir=${indir:+"$indir"/} && - local file=${2:-"$1.t"} && + local file="${2:-"$1.t"}" && if test -n "$append" then $echo "${3-$1}" >>"$indir$file" @@ -1672,7 +1672,7 @@ test_oid () { # Insert a slash into an object ID so it can be used to reference a location # under ".git/objects". For example, "deadbeef..." becomes "de/adbeef..". test_oid_to_path () { - local basename=${1#??} + local basename="${1#??}" echo "${1%$basename}/$basename" } @@ -1840,7 +1840,7 @@ test_readlink () { # An optional increment to the magic timestamp may be specified as second # argument. test_set_magic_mtime () { - local inc=${2:-0} && + local inc="${2:-0}" && local mtime=$((1234567890 + $inc)) && test-tool chmtime =$mtime "$1" && test_is_magic_mtime "$1" $inc @@ -1853,7 +1853,7 @@ test_set_magic_mtime () { # argument. Usually, this should be the same increment which was used for # the associated test_set_magic_mtime. test_is_magic_mtime () { - local inc=${2:-0} && + local inc="${2:-0}" && local mtime=$((1234567890 + $inc)) && echo $mtime >.git/test-mtime-expect && test-tool chmtime --get "$1" >.git/test-mtime-actual && From patchwork Sat Apr 6 00:09:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13619608 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) (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 1C9F9BE4F for ; Sat, 6 Apr 2024 00:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.108.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362161; cv=none; b=g5ooQKndjoshTMRofYc3N39CEdK+oxGg3Qmzzgq72AUZKRRYBj5cBo4J7Yk3pB+/IW/oziHVSeY2rWpCYeubhuyyXzkdasrsuudXC/7rdEtjnwUouwNyjgWMDRUU6nj0J5KwghKjT0VcV11fth/+NDmCzoylh+x6VcoqbZ3iMjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362161; c=relaxed/simple; bh=DdNN9U5QEGCtxowbXamR6TnI77ik9x/ygD2ky1a+zPA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P55lykBkLt5pjndYjJMpCYpHUgCbYlVT+840/4Ql6+pKt7wcZo9ivnYn/opOacCo5UVfP+3L+DpRbnCCYmgtKjcHpjhop3npfYgsqpIlIScNBe/OsAQcE6qHh4qGc2Rv3co15EnRgV3qC/ikvHtpcX3Fzts5iWH0UK+Yp99wOQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=v6Rqx9RG; arc=none smtp.client-ip=64.147.108.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="v6Rqx9RG" Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 268771DB1FE; Fri, 5 Apr 2024 20:09:19 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=DdNN9U5QEGCtxowbXamR6TnI7 7ik9x/ygD2ky1a+zPA=; b=v6Rqx9RGSwhsvtk+FnODZcrDxzoIFNjLI/58XPFHU PnJPk7A/WGAa0Yhq01laggR/8sgBhTJdu0ldqp1uZSM8lvOCslq85f1nvpmiQzwm HvthCIeEiXF5VnumU78XABzn+p4Sd7jzk/p+CuaOvf4XC2HNmutIbKCvMCUWv7IJ DQ= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 1F0181DB1FC; Fri, 5 Apr 2024 20:09:19 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.125.229.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 828641DB1FB; Fri, 5 Apr 2024 20:09:18 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 6/6] t: teach lint that RHS of 'local VAR=VAL' needs to be quoted Date: Fri, 5 Apr 2024 17:09:02 -0700 Message-ID: <20240406000902.3082301-7-gitster@pobox.com> X-Mailer: git-send-email 2.44.0-501-g19981daefd In-Reply-To: <20240406000902.3082301-1-gitster@pobox.com> References: <20240406000902.3082301-1-gitster@pobox.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: E9604038-F3A9-11EE-8FE7-25B3960A682E-77302942!pb-smtp2.pobox.com Teach t/check-non-portable-shell.pl that right hand side of the assignment done with "local VAR=VAL" need to be quoted. We deliberately target only VAL that begins with $ so that we can catch - $variable_reference and positional parameter reference like $4 - $(command substitution) - ${variable_reference-with_magic} while excluding - $'\n' that is a bash-ism freely usable in t990[23] - $(( arithmetic )) whose result should be $IFS safe. - $? that also is $IFS safe Signed-off-by: Junio C Hamano --- t/check-non-portable-shell.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index dd8107cd7d..b2b28c2ced 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -47,6 +47,8 @@ sub err { /\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)'; /\b[ef]grep\b/ and err 'egrep/fgrep obsolescent (use grep -E/-F)'; /\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 err '"FOO=bar shell_func" assignment extends beyond "shell_func"'; $line = ''; From patchwork Sat Apr 6 00:23:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13619611 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) (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 D110036B for ; Sat, 6 Apr 2024 00:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.108.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362995; cv=none; b=RJcn14fhJG6J7JKyjE5KA/zzGo9Nfg1Y+cs35kZrcttnGiYzoK0PefO3kmbCIgfQTA/OByIEDyXn3npn8Zsc2+ioqIV/Z/+eI+83u81WNBT5kCIvyfzTM2mXmcb9lwgnmoe0uw9CF1BfCYr7W7bah0qofWElnsRNx6uSYeCAXlQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712362995; c=relaxed/simple; bh=lnvSReRq4rauhMOgBWb1eXzJPMUu5XqogkVCqtoufoA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=FjVAtEh3MAZvhBp7xJAgXvTODnIn87L1JClTs53AYT2wInGB1MaauqLn5pck6duO9MYsGdS6TmOOLrTQUJa3UFYlfVsS/f8Uf/bkknaKOXcuvx3lW7r6BTZS9p3XvKpkdx7I2l0UtrBDBjTKRmaY2NDfXUvh+9iGE+urdzTXK4A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=BTRiU6Bu; arc=none smtp.client-ip=64.147.108.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="BTRiU6Bu" Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 9A85A1DB409; Fri, 5 Apr 2024 20:23:12 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=lnvSReRq4rauhMOgBWb1eXzJPMUu5XqogkVCqt oufoA=; b=BTRiU6ButsFi475/Z12w8jShpQG/TOXdEXcHI2TLsouQjKKGovC9uc FK2m2RPpWYbwnfQLW/l/iWcINu1nNmcJePORqNDxEbbOc8VjoqPv5J8xR7WKAEP7 cHcutBUd2ZlBBdqcnajlM0mpffOSvbAEARWn1oA3YaR5YQJ6XxdrE= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 9303D1DB408; Fri, 5 Apr 2024 20:23:12 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.125.229.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id EAA4E1DB407; Fri, 5 Apr 2024 20:23:11 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Cc: Patrick Steinhardt Subject: [PATCH 7/6] t0610: local VAR="VAL" fix In-Reply-To: <20240406000902.3082301-1-gitster@pobox.com> (Junio C. Hamano's message of "Fri, 5 Apr 2024 17:08:56 -0700") References: <20240406000902.3082301-1-gitster@pobox.com> Date: Fri, 05 Apr 2024 17:23:10 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: DA234E10-F3AB-11EE-802B-25B3960A682E-77302942!pb-smtp2.pobox.com The series was based on maint and fixes all the tests that exist there, but we have acquired a few more. Signed-off-by: Junio C Hamano --- t/t0610-reftable-basics.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git i/t/t0610-reftable-basics.sh w/t/t0610-reftable-basics.sh index 686781192e..c8074ebab2 100755 --- i/t/t0610-reftable-basics.sh +++ w/t/t0610-reftable-basics.sh @@ -83,7 +83,7 @@ test_expect_success 'init: reinitializing reftable with files backend fails' ' test_expect_perms () { local perms="$1" local file="$2" - local actual=$(ls -l "$file") && + local actual="$(ls -l "$file")" && case "$actual" in $perms*) From patchwork Sat Apr 6 00:28:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13619616 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) (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 B2EFD620 for ; Sat, 6 Apr 2024 00:28:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.228.157.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712363303; cv=none; b=u3BruZ0nofWPVD0cL3C2+xwxsOlDGiFyYvWzT2n2Jdi2Ox8SwCc312SCcwHyhYvVTEQ1b7FVP9gXq5pXkz8kT2hnyGKYa5F0lYLP7gjK+Rmu35VxVOLamawxwcOQRRVAIjPCJWhs8CJ+UAhejeGCyZJo8Sq8VNCEClMTtwS9O7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712363303; c=relaxed/simple; bh=t5y9siuXxmWAqXMXORTJQYvbzZy9rwKxNPcL2wwe9UI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=mk1P6wffx0hZxTO16m+RquaejunDKg14mTrxks8fD7I1VyrMg6tCifole9MAe+3zoCZfz3V/zIXp1VQdxKn7AAlATILAUA4HXRHxqty25pbEAFGTWd1lZzytFkKkS7qIAsxJgQ1LhDD0WO88BB7HRK7/1b5JZ0KsPPDfxsVL4UQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=OZhIkEgl; arc=none smtp.client-ip=173.228.157.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="OZhIkEgl" Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 33D1327CEA; Fri, 5 Apr 2024 20:28:21 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=t5y9siuXxmWAqXMXORTJQYvbzZy9rwKxNPcL2w we9UI=; b=OZhIkEglDrjzb1RK1i2BoeuiASXgwdY2toxUbDSrk82LjQ8poKyFLM UM8braTtvxoN+FvYV86JhjjAeWXWjDBkejf+c0WDYztuSXywbd8yDPCXYJ/BGhTK m4B9t1CemVmnDeWd53dpdoYxwf5vHnZhlHhQq5yjMkymm4EGQuWXI= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 2B83927CE9; Fri, 5 Apr 2024 20:28:21 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.125.229.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id A08CA27CE8; Fri, 5 Apr 2024 20:28:17 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Cc: "Eric W. Biederman" Subject: [PATCH 8/6] t1016: local VAR="VAL" fix In-Reply-To: <20240406000902.3082301-1-gitster@pobox.com> (Junio C. Hamano's message of "Fri, 5 Apr 2024 17:08:56 -0700") References: <20240406000902.3082301-1-gitster@pobox.com> Date: Fri, 05 Apr 2024 17:28:16 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Pobox-Relay-ID: 90590436-F3AC-11EE-86B4-F515D2CDFF5E-77302942!pb-smtp20.pobox.com The series was based on maint and fixes all the tests that exist there, but we have acquired a few more. I suspect that the values assigned in many of these places are $IFS safe, and this is primarily to squelch the linter than adding a necessary workaround for buggy dash. Signed-off-by: Junio C Hamano --- t/t1016-compatObjectFormat.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git c/t/t1016-compatObjectFormat.sh w/t/t1016-compatObjectFormat.sh index 8132cd37b8..be3206a16f 100755 --- c/t/t1016-compatObjectFormat.sh +++ w/t/t1016-compatObjectFormat.sh @@ -79,7 +79,7 @@ commit2_oid () { } del_sigcommit () { - local delete=$1 + local delete="$1" if test "$delete" = "sha256" ; then local pattern="gpgsig-sha256" @@ -91,8 +91,8 @@ del_sigcommit () { del_sigtag () { - local storage=$1 - local delete=$2 + local storage="$1" + local delete="$2" if test "$storage" = "$delete" ; then local pattern="trailer" @@ -181,7 +181,7 @@ done cd "$base" compare_oids () { - test "$#" = 5 && { local PREREQ=$1; shift; } || PREREQ= + test "$#" = 5 && { local PREREQ="$1"; shift; } || PREREQ= local type="$1" local name="$2" local sha1_oid="$3" @@ -193,8 +193,8 @@ compare_oids () { git --git-dir=repo-sha1/.git rev-parse --output-object-format=sha256 ${sha1_oid} > ${name}_sha1_sha256_found git --git-dir=repo-sha256/.git rev-parse --output-object-format=sha1 ${sha256_oid} > ${name}_sha256_sha1_found - local sha1_sha256_oid=$(cat ${name}_sha1_sha256_found) - local sha256_sha1_oid=$(cat ${name}_sha256_sha1_found) + local sha1_sha256_oid="$(cat ${name}_sha1_sha256_found)" + local sha256_sha1_oid="$(cat ${name}_sha256_sha1_found)" test_expect_success $PREREQ "Verify ${type} ${name}'s sha1 oid" ' git --git-dir=repo-sha256/.git rev-parse --output-object-format=sha1 ${sha256_oid} > ${name}_sha1 &&