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

[PATCH] git-rebase--interactive.sh: Quote arguments to test

From
Michael W. Olson <mwolson@gnu.org>
Date
Oct 15, 2007, 17:48 UTC
Message-ID
<87odf0clqs.fsf@hariken.mwolson.org>

If /bin/sh is /bin/dash, then the script will display an error if $parent_sha1 is undefined. This patch works fixes the issue by quoting both arguments to `test'. Arguments composed solely of variable expansions should always be quoted, unless we know for certain that the contents are defined.

Signed-off-by: Michael W. Olson <mwolson@gnu.org>
---
Resending, this time directly to the mailing list instead of via Gmane.
 git-rebase--interactive.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 050140d..8a03062 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -110,7 +110,7 @@ pick_one () {
 	parent_sha1=$(git rev-parse --verify $sha1^) ||
 		die "Could not get the parent of $sha1"
 	current_sha1=$(git rev-parse --verify HEAD)
-	if test $no_ff$current_sha1 = $parent_sha1; then
+	if test "$no_ff$current_sha1" = "$parent_sha1"; then
 		output git reset --hard $sha1
 		test "a$1" = a-n && output git reset --soft $current_sha1
 		sha1=$(git rev-parse --short $sha1)
-- 
1.5.3.4
Message 1 of 1 in “git-rebase--interactive.sh: Quote arguments to test”
  1. git-rebase--interactive.sh: Quote arguments to testMichael W. Olson, Oct 15, 2007

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.