Skip to contentSkip to conversation

git-rebase.sh: Use POSIX/Susv command substitution instead of backticks

PATCH In review Jari Aalto 4 participants 7 messages Jun 15, 2016

lore
Share & tools
lore

Jari Aalto

author
#0 lore raw

PATCH 1/1 git-rebase.sh: Use POSIX/Susv command substitution instead of backticks

Use redable $(<command>) syntax instead of backtics in code. See The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition

Signed-off-by Jari Aalto <jari.aalto AT cante.net>

---
See http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03

 git-rebase.sh |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
git-rebase.sh +7 -7
index bdcea0e..d2b329f 100755
@@ -60,7 +60,7 @@ continue_merge () {
 		die "$RESOLVEMSG"
 	fi
 
-	cmt=`cat "$dotest/current"`
+	cmt=$(cat "$dotest/current")
 	if ! git diff-index --quiet HEAD --
 	then
 		if ! git-commit -C "$cmt"
@@ -75,7 +75,7 @@ continue_merge () {
 	fi
 	git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
 
-	prev_head=`git rev-parse HEAD^0`
+	prev_head=$(git rev-parse HEAD^0)
 	# save the resulting commit so we can read-tree on it later
 	echo "$prev_head" > "$dotest/prev_head"
 
@@ -233,7 +233,7 @@ do
 	-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
 		case "$#,$1" in
 		*,*=*)
-			strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;;
+			strategy=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
 		1,*)
 			usage ;;
 		*)
@@ -295,7 +295,7 @@ esac
 
 # The upstream head must be given.  Make sure it is valid.
 upstream_name="$1"
-upstream=`git rev-parse --verify "${upstream_name}^0"` ||
+upstream=$(git rev-parse --verify "${upstream_name}^0") ||
     die "invalid upstream $upstream_name"
 
 # Make sure the branch to rebase onto is valid.
@@ -318,9 +318,9 @@ case "$#" in
 	git-checkout "$2" || usage
 	;;
 *)
-	if branch_name=`git symbolic-ref -q HEAD`
+	if branch_name=$(git symbolic-ref -q HEAD)
 	then
-		branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'`
+		branch_name=$(expr "z$branch_name" : 'zrefs/heads/\(.*\)')
 	else
 		branch_name=HEAD ;# detached
 	fi
@@ -399,7 +399,7 @@ echo "$orig_head" > "$dotest/orig-head"
 echo "$head_name" > "$dotest/head-name"
 
 msgnum=0
-for cmt in `git rev-list --reverse --no-merges "$upstream"..ORIG_HEAD`
+for cmt in $(git rev-list --reverse --no-merges "$upstream"..ORIG_HEAD)
 do
 	msgnum=$(($msgnum + 1))
 	echo "$cmt" > "$dotest/cmt.$msgnum"
Signature · 5 lines
1.5.4-rc5.GIT-dirty


-- 
Welcome to FOSS revolution: we fix and modify until it shines
#1 lore raw

Hi,

Quoted 2 lines · Jari Aalto

Use redable $(<command>) syntax instead of backtics in code. See The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition

Sorry, I am not quite sure if this patch is worth it: either you want to clean this up in _all_ of our shell scripts, or you leave it. Or you fix it in those parts that you touch anyway, but again leave the rest as-are.

Ciao,
Dscho

author
#2 lore raw

* Tue 2008-02-05 Johannes Schindelin <[email protected]>
* Message-Id: [email protected]

Quoted 9 lines

Hi,

Quoted 2 lines · Jari Aalto

Use redable $(<command>) syntax instead of backtics in code. See The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition

Sorry, I am not quite sure if this patch is worth it: either you want to clean this up in _all_ of our shell scripts, or you leave it.

Yes, that's the plan. This is just a start.

Jari

Signature · 1 line
Welcome to FOSS revolution: we fix and modify until it shines
#3 lore raw

Hi,

Quoted 5 lines · Jari Aalto

* Tue 2008-02-05 Johannes Schindelin <[email protected]>
* Message-Id: [email protected]

Quoted 2 lines · Jari Aalto
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Use redable $(<command>) syntax instead of backtics in code. See The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition

Sorry, I am not quite sure if this patch is worth it: either you want to clean this up in _all_ of our shell scripts, or you leave it.

Yes, that's the plan. This is just a start.

Again, you failed to address me. FYI my email address is [email protected]. Thank you very much.

"This is just a start" is not good enough. First, you have to defend why this is a good change. It does not really fix anything.

And then you have to do it for all scripts in one go. Mind you, it is not really complicated: just one call to perl.

Hth,
Dscho

#4 lore raw
Quoted 2 lines · Johannes Schindelin

And then you have to do it for all scripts in one go. Mind you, it is not really complicated: just one call to perl.

Please do not do this. If other people have pending changes, "cleanup for clean-up's sake" would create conflicts for no good reason.

There are only two cases such a clean-up patch is good:

(1) When the maintainer is not yet accepting any patches after a release-freeze and there is no pending patches from the community, and/or if you can convince people with pending patches to rebase on top of the clean-up because the current codebase is so unmaintainably bad, then a whole-tree clean-up patch should go in before anything else, forcing everybody to rebase on top of it;

(2) If you will be working on the code in an area, you may want to have the first one in the series a "pure clean-up and nothing else" of the whole area, and then build your real changes on top. You still need to coordinate with people whose patches may get hit by your clean-ups, but you have to do this anyway because you will have conflicts from your "real changes".

Any other "clean-up patch" would result in a not-so-appreciated code churn. Please don't encourage it.

#5 lore raw
Quoted 27 lines · Junio C Hamano
Quoted 2 lines · Johannes Schindelin

And then you have to do it for all scripts in one go. Mind you, it is not really complicated: just one call to perl.

Please do not do this. If other people have pending changes, "cleanup for clean-up's sake" would create conflicts for no good reason.

There are only two cases such a clean-up patch is good:

(1) When the maintainer is not yet accepting any patches after a release-freeze and there is no pending patches from the community, and/or if you can convince people with pending patches to rebase on top of the clean-up because the current codebase is so unmaintainably bad, then a whole-tree clean-up patch should go in before anything else, forcing everybody to rebase on top of it;

(2) If you will be working on the code in an area, you may want to have the first one in the series a "pure clean-up and nothing else" of the whole area, and then build your real changes on top. You still need to coordinate with people whose patches may get hit by your clean-ups, but you have to do this anyway because you will have conflicts from your "real changes".

Quoted 2 lines

Any other "clean-up patch" would result in a not-so-appreciated code churn. Please don't encourage it.

Just to make sure Jari does not get a wrong idea,

My "Please don't" is meant against Johannes's "Do it all if you do it".

If Jari did the patch as the first step of making real changes to "git rebase" (making -i not forcing -m, perhaps), it is the right thing to have a clean-up patch as a preparatory step, before starting the real work in later patches in the series. And such a clean-up patch should not inflict useless code churn on other commands.

So a single patch only to git-rebase is acceptable if that is what Jari is planning to do: preparatory clean-up before bringing a real improvement in.

#6 lore raw
In reply to Johannes Schindelin
Quoted 7 lines · Johannes Schindelin <Johannes.Schindelin <at> gmx.de> writes:
Quoted 4 lines
Quoted 4 lines · Jari Aalto
Quoted 3 lines

Use redable $(<command>) syntax instead of backtics in code. See The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition

And then you have to do it for all scripts in one go. Mind you, it is not really complicated: just one call to perl.

You still have to check all backslashes within the changed command; some you may now have to remove.

Cheers,
Ralf