{"thread":{"id":"37651","subject":"[PATCH] t0090: avoid passing empty string to printf %d","startedAt":"2014-09-30T17:42:03Z","lastAt":"2014-09-30T17:42:03Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"250040","messageId":"542AEB6B.1020509@web.de","threadId":"37651","inReplyTo":null,"subject":"[PATCH] t0090: avoid passing empty string to printf %d","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2014-09-30T17:42:03Z","receivedAt":"2014-09-30T17:42:03Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"FreeBSD's printf(1) doesn't accept empty strings for numerical format\nspecifiers:\n\n\t$ printf \"%d\\n\" \"\" >/dev/null; echo $?\n\tprintf: : expected numeric value\n\t1\n\nInitialize the AWK variable c to make sure the shell variable\nsubtree_count always contains a numerical value, in order to keep the\nsubsequently called printf happy.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n t/t0090-cache-tree.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh\nindex f9648a8..158cf4f 100755\n--- a/t/t0090-cache-tree.sh\n+++ b/t/t0090-cache-tree.sh\n@@ -22,7 +22,7 @@ generate_expected_cache_tree_rec () {\n \t# ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux\n \t# We want to count only foo because it's the only direct child\n \tsubtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) &&\n-\tsubtree_count=$(echo \"$subtrees\"|awk '$1 {++c} END {print c}') &&\n+\tsubtree_count=$(echo \"$subtrees\"|awk -v c=0 '$1 {++c} END {print c}') &&\n \tentries=$(git ls-files|wc -l) &&\n \tprintf \"SHA $dir (%d entries, %d subtrees)\\n\" \"$entries\" \"$subtree_count\" &&\n \tfor subtree in $subtrees\n-- \n2.1.1\n"}]}