git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-filter-branch: avoid collisions with variables in eval'ed commands

From
newren@gmail.com <newren@gmail.com>
Date
Mar 25, 2009, 21:51 UTC
Message-ID
<1238017861-15292-1-git-send-email-newren@gmail.com>
In-Reply-To
<51419b2c0903251433s75775206x556fc2d65a347d7d@mail.gmail.com>
From: Elijah Newren <newren@gmail.com>

Avoid using simple variable names like 'i', since user commands are eval'ed and may clash with and overwrite our values.

Signed-off-by: Elijah Newren <newren@gmail.com>
---

If you have a different preference for the variable name, I'd be happy to change it (again). All I care about is avoiding conflicts with what people might pass in their scripts.

 git-filter-branch.sh |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 20f6f51..b90d3df 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -272,10 +272,10 @@ test $commits -eq 0 && die "Found nothing to rewrite"
 
 # Rewrite the commits
 
-i=0
+git_filter_branch__commit_count=0
 while read commit parents; do
-	i=$(($i+1))
-	printf "\rRewrite $commit ($i/$commits)"
+	git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))
+	printf "\rRewrite $commit ($git_filter_branch__commit_count/$commits)"
 
 	case "$filter_subdir" in
 	"")
-- 
1.6.0.6
Previous: Elijah NewrenNext: Petr Baudis
Message 4 of 6 in “git-filter-branch: avoid collisions with variables in eval'ed commands”
  1. git-filter-branch: avoid collisions with variables in eval'ed commandsnewren@gmail.com, Mar 25, 2009
  2. Petr BaudisMar 25, 2009
  3. Elijah NewrenMar 25, 2009
  4. newren@gmail.comMar 25, 2009
  5. Petr BaudisMar 25, 2009
  6. Junio C HamanoMar 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.