Skip to content

Commit

Permalink
merge-one-file: fix "expr: non-numeric argument"
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
jaysoffian authored and gitster committed Oct 6, 2011
1 parent e923eae commit d30db56
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion git-merge-one-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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"
Expand Down

0 comments on commit d30db56

Please sign in to comment.