From: Junio C Hamano <gitster@pobox.com>
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 [thread overview]
Message-ID: <20240406000902.3082301-4-gitster@pobox.com> (raw)
In-Reply-To: <20240406000902.3082301-1-gitster@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 <gitster@pobox.com>
---
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
--
2.44.0-501-g19981daefd
next prev parent reply other threads:[~2024-04-06 0:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-06 0:08 [PATCH 0/6] local VAR="VAL" Junio C Hamano
2024-04-06 0:08 ` [PATCH 1/6] CodingGuidelines: describe "export VAR=VAL" rule Junio C Hamano
2024-04-06 5:11 ` Eric Sunshine
2024-04-06 5:47 ` Junio C Hamano
2024-04-06 9:15 ` Andreas Schwab
2024-04-06 17:03 ` Junio C Hamano
2024-04-06 17:34 ` Eric Sunshine
2024-04-06 0:08 ` [PATCH 2/6] CodingGuidelines: quote assigned value in 'local var=$val' Junio C Hamano
2024-04-06 1:29 ` rsbecker
2024-04-06 2:29 ` Junio C Hamano
2024-04-06 5:16 ` Eric Sunshine
2024-04-06 5:40 ` Junio C Hamano
2024-04-06 0:08 ` Junio C Hamano [this message]
2024-04-08 15:30 ` [PATCH 3/6] t: local VAR="VAL" (quote positional parameters) Patrick Steinhardt
2024-04-08 17:23 ` Junio C Hamano
2024-04-06 0:09 ` [PATCH 4/6] t: local VAR="VAL" (quote command substitution) Junio C Hamano
2024-04-06 0:09 ` [PATCH 5/6] t: local VAR="VAL" (quote ${magic-reference}) Junio C Hamano
2024-04-06 0:09 ` [PATCH 6/6] t: teach lint that RHS of 'local VAR=VAL' needs to be quoted Junio C Hamano
2024-04-07 1:43 ` Jeff King
2024-04-08 17:31 ` Junio C Hamano
2024-04-08 20:40 ` Jeff King
2024-04-06 0:23 ` [PATCH 7/6] t0610: local VAR="VAL" fix Junio C Hamano
2024-04-06 0:28 ` [PATCH 8/6] t1016: " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240406000902.3082301-4-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).