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

[PATCH] merge-one-file: fix "expr: non-numeric argument"

From
Jay Soffian <jaysoffian@gmail.com>
Date
Oct 6, 2011, 18:25 UTC
Message-ID
<1317925555-65237-1-git-send-email-jaysoffian@gmail.com>

When invoking expr to compare two numbers, don't quote the variables which are the output of 'wc -c'. On OS X, this output includes spaces, which expr balks at:

  $ sz0=`wc -c </etc/passwd`
  $ sz1=`wc -c </etc/passwd`
  $ echo "'$sz0'"
  '    3667'
  $ expr "$sz0" \< "$sz1" \* 2
  expr: non-numeric argument
  $ expr $sz0 \< $sz1 \* 2
  1
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
Noticed this while working on the CHERRY_PICK_HEAD issue.
 git-merge-one-file.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index 7aeb96952f..f612cb847a 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -117,7 +117,7 @@ case "${1:-.}${2:-.}${3:-.}" in
 
 		# If we do not have enough common material, it is not
 		# worth trying two-file merge using common subsections.
-		expr "$sz0" \< "$sz1" \* 2 >/dev/null || : >$orig
+		expr $sz0 \< $sz1 \* 2 >/dev/null || : >$orig
 		;;
 	*)
 		echo "Auto-merging $4"
-- 
1.7.7.144.gbfcf9.dirty
Next: Junio C Hamano
Message 1 of 2 in “merge-one-file: fix "expr: non-numeric argument"”
  1. merge-one-file: fix "expr: non-numeric argument"Jay Soffian, Oct 6, 2011
  2. Junio C HamanoOct 6, 2011

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.