* [PATCH] t6423-merge-rename-directories.sh: use the $(...) construct for command substitution
@ 2022-02-22 8:46 Elia Pinto
2022-02-22 14:06 ` Derrick Stolee
0 siblings, 1 reply; 2+ messages in thread
From: Elia Pinto @ 2022-02-22 8:46 UTC (permalink / raw)
To: git; +Cc: Elia Pinto
The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.
The backquoted form is the traditional method for command
substitution, and is supported by POSIX. However, all but the
simplest uses become complicated quickly. In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.
The patch was generated by:
for _f in $(find . -name "*.sh")
do
shellcheck -i SC2006 -f diff ${_f} | ifne git apply -p2
done
and then carefully proof-read.
Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
t/t6423-merge-rename-directories.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/t/t6423-merge-rename-directories.sh b/t/t6423-merge-rename-directories.sh
index 5b81a130e9..479db32cd6 100755
--- a/t/t6423-merge-rename-directories.sh
+++ b/t/t6423-merge-rename-directories.sh
@@ -4421,14 +4421,14 @@ test_setup_12c1 () {
git checkout A &&
git mv node2/ node1/ &&
- for i in `git ls-files`; do echo side A >>$i; done &&
+ for i in $(git ls-files); do echo side A >>$i; done &&
git add -u &&
test_tick &&
git commit -m "A" &&
git checkout B &&
git mv node1/ node2/ &&
- for i in `git ls-files`; do echo side B >>$i; done &&
+ for i in $(git ls-files); do echo side B >>$i; done &&
git add -u &&
test_tick &&
git commit -m "B"
@@ -4511,7 +4511,7 @@ test_setup_12c2 () {
git checkout A &&
git mv node2/ node1/ &&
- for i in `git ls-files`; do echo side A >>$i; done &&
+ for i in $(git ls-files); do echo side A >>$i; done &&
git add -u &&
echo leaf5 >node1/leaf5 &&
git add node1/leaf5 &&
@@ -4520,7 +4520,7 @@ test_setup_12c2 () {
git checkout B &&
git mv node1/ node2/ &&
- for i in `git ls-files`; do echo side B >>$i; done &&
+ for i in $(git ls-files); do echo side B >>$i; done &&
git add -u &&
echo leaf6 >node2/leaf6 &&
git add node2/leaf6 &&
@@ -4759,7 +4759,7 @@ test_setup_12f () {
echo g >dir/subdir/tweaked/g &&
echo h >dir/subdir/tweaked/h &&
test_seq 20 30 >dir/subdir/tweaked/Makefile &&
- for i in `test_seq 1 88`; do
+ for i in $(test_seq 1 88); do
echo content $i >dir/unchanged/file_$i
done &&
git add . &&
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] t6423-merge-rename-directories.sh: use the $(...) construct for command substitution
2022-02-22 8:46 [PATCH] t6423-merge-rename-directories.sh: use the $(...) construct for command substitution Elia Pinto
@ 2022-02-22 14:06 ` Derrick Stolee
0 siblings, 0 replies; 2+ messages in thread
From: Derrick Stolee @ 2022-02-22 14:06 UTC (permalink / raw)
To: Elia Pinto, git
On 2/22/2022 3:46 AM, Elia Pinto wrote:
> The Git CodingGuidelines prefer the $(...) construct for command
> substitution instead of using the backquotes `...`.
>
> The backquoted form is the traditional method for command
> substitution, and is supported by POSIX. However, all but the
> simplest uses become complicated quickly. In particular, embedded
> command substitutions and/or the use of double quotes require
> careful escaping with the backslash character.
This message has some strange left-padding. Could you reduce that
whitespace for the majority of your message?
> The patch was generated by:
>
> for _f in $(find . -name "*.sh")
> do
> shellcheck -i SC2006 -f diff ${_f} | ifne git apply -p2
> done
Having some left-padding makes sense for this example.
Also, thanks for sharing this automation!
> and then carefully proof-read.
> - for i in `git ls-files`; do echo side A >>$i; done &&
> + for i in $(git ls-files); do echo side A >>$i; done &&
> - for i in `git ls-files`; do echo side B >>$i; done &&
> + for i in $(git ls-files); do echo side B >>$i; done &&
> - for i in `git ls-files`; do echo side A >>$i; done &&
> + for i in $(git ls-files); do echo side A >>$i; done &&
> - for i in `git ls-files`; do echo side B >>$i; done &&
> + for i in $(git ls-files); do echo side B >>$i; done &&
> - for i in `test_seq 1 88`; do
> + for i in $(test_seq 1 88); do
These changes make sense. Thanks!
-Stolee
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-22 14:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-22 8:46 [PATCH] t6423-merge-rename-directories.sh: use the $(...) construct for command substitution Elia Pinto
2022-02-22 14:06 ` Derrick Stolee
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 NNTP newsgroup(s).