{"thread":{"id":"680","subject":"[PATCH] Fix use of wc in t0000-basic","startedAt":"2005-05-21T00:49:13Z","lastAt":"2005-05-21T17:24:57Z","messageCount":10,"participants":["Daniel Barkalow","Sean","Junio C Hamano","Herbert Xu"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"3662","messageId":"Pine.LNX.4.21.0505202045580.30848-100000@iabervon.org","threadId":"680","inReplyTo":null,"subject":"[PATCH] Fix use of wc in t0000-basic","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-05-21T00:49:13Z","receivedAt":"2005-05-21T00:49:13Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"The version of wc I have (GNU textutils-2.1) puts spaces at the beginning\nof lines. This patch should work for any version of wc.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\nAcked-by: Junio C Hamano <junkio@cox.net>\nIndex: t/t0000-basic.sh\n===================================================================\n--- 58741c69570705801db4b785681790d636475695/t/t0000-basic.sh  (mode:100755 sha1:9a557129d98b499bcd601903d6646de29ba4bfc5)\n+++ uncommitted/t/t0000-basic.sh  (mode:100755)\n@@ -32,7 +32,7 @@\n find .git/objects -type d -print >full-of-directories\n test_expect_success \\\n     '.git/objects should have 256 subdirectories.' \\\n-    'test \"$(wc -l full-of-directories | sed -e \"s/ .*//\")\" = 257'\n+    'test $(cat full-of-directories | wc -l) = 257'\n \n ################################################################\n # Basics of the basics\n\n\n"},{"id":"3663","messageId":"4600.10.10.10.24.1116637737.squirrel@linux1","threadId":"680","inReplyTo":"Pine.LNX.4.21.0505202045580.30848-100000@iabervon.org","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2005-05-21T01:08:57Z","receivedAt":"2005-05-21T01:08:57Z","isPatch":true,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Fri, May 20, 2005 8:49 pm, Daniel Barkalow said:\n> The version of wc I have (GNU textutils-2.1) puts spaces at the beginning\n> of lines. This patch should work for any version of wc.\n>\n> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> Acked-by: Junio C Hamano <junkio@cox.net>\n> Index: t/t0000-basic.sh\n> ===================================================================\n> --- 58741c69570705801db4b785681790d636475695/t/t0000-basic.sh\n> (mode:100755 sha1:9a557129d98b499bcd601903d6646de29ba4bfc5)\n> +++ uncommitted/t/t0000-basic.sh  (mode:100755)\n> @@ -32,7 +32,7 @@\n>  find .git/objects -type d -print >full-of-directories\n>  test_expect_success \\\n>      '.git/objects should have 256 subdirectories.' \\\n> -    'test \"$(wc -l full-of-directories | sed -e \"s/ .*//\")\" = 257'\n> +    'test $(cat full-of-directories | wc -l) = 257'\n>\n>  ################################################################\n>  # Basics of the basics\n>\n\n\nYou can't do \"wc -l filename\" because some versionso of \"wc\" then include\nthe filename in their output and confuse things.   That was the reason to\nuse \"cat\" in the first place.  If you're going to use sed, just do away\nwith wc altogether:\n\nsed -ne '$=' full-of-directories\n\nAnd that should work everywhere to get a line count.\n\nCheers,\nSean\n\n\n"},{"id":"3664","messageId":"Pine.LNX.4.21.0505202109460.30848-100000@iabervon.org","threadId":"680","inReplyTo":"4600.10.10.10.24.1116637737.squirrel@linux1","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-05-21T01:10:38Z","receivedAt":"2005-05-21T01:10:38Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 20 May 2005, Sean wrote:\n\n> You can't do \"wc -l filename\" because some versionso of \"wc\" then include\n> the filename in their output and confuse things.   That was the reason to\n> use \"cat\" in the first place.\n\nYou're reading my patch backwards.\n\n\t-Daniel\n*This .sig left intentionally blank*\n\n"},{"id":"3665","messageId":"4616.10.10.10.24.1116637985.squirrel@linux1","threadId":"680","inReplyTo":"Pine.LNX.4.21.0505202109460.30848-100000@iabervon.org","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2005-05-21T01:13:05Z","receivedAt":"2005-05-21T01:13:05Z","isPatch":true,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Fri, May 20, 2005 9:10 pm, Daniel Barkalow said:\n> On Fri, 20 May 2005, Sean wrote:\n>\n>> You can't do \"wc -l filename\" because some versionso of \"wc\" then\n>> include\n>> the filename in their output and confuse things.   That was the reason\n>> to\n>> use \"cat\" in the first place.\n>\n> You're reading my patch backwards.\n>\n\nYes, i was.   But presumably someone was stripping the whitespace from wc\nfor a reason?   Either way the sed-only solution seems a little cleaner.\n\nSean\n\n\n"},{"id":"3666","messageId":"Pine.LNX.4.21.0505202113500.30848-100000@iabervon.org","threadId":"680","inReplyTo":"4616.10.10.10.24.1116637985.squirrel@linux1","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-05-21T01:16:22Z","receivedAt":"2005-05-21T01:16:22Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 20 May 2005, Sean wrote:\n\n> Yes, i was.   But presumably someone was stripping the whitespace from wc\n> for a reason?   Either way the sed-only solution seems a little cleaner.\n\nJunio was stripping the filename (not whitespace) from wc, not knowing\nthat it could be suppressed by using stdin. This didn't work with versions\nof wc that put whitespace at the beginning. I think the sed-only solution\nis far more obscure and no cleaner than cat and wc.\n\n\t-Daniel\n*This .sig left intentionally blank*\n\n"},{"id":"3669","messageId":"7vzmuppd4y.fsf@assigned-by-dhcp.cox.net","threadId":"680","inReplyTo":"Pine.LNX.4.21.0505202113500.30848-100000@iabervon.org","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-21T01:43:25Z","receivedAt":"2005-05-21T01:43:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"DB\" == Daniel Barkalow <barkalow@iabervon.org> writes:\n\nDB> Junio was stripping the filename (not whitespace) from wc, not knowing\nDB> that it could be suppressed by using stdin.\n\nActually the reason I did so initially was because I recalled\nseeing a wc that said \"-\" instead of omitting the filename.  I\ndo not have access to those obscure Unixen so I cannot these\nthings easily anymore, though.\n\nDB> of wc that put whitespace at the beginning. I think the\nDB> sed-only solution is far more obscure and no cleaner than\nDB> cat and wc.\n\nThis I tend to agree, but that is probably one of the most\nportable.\n\n"},{"id":"3692","messageId":"E1DZRMi-00021X-00@gondolin.me.apana.org.au","threadId":"680","inReplyTo":"Pine.LNX.4.21.0505202045580.30848-100000@iabervon.org","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Herbert Xu","fromEmail":"herbert@gondor.apana.org.au","sentAt":"2005-05-21T10:37:56Z","receivedAt":"2005-05-21T10:37:56Z","isPatch":true,"sender":{"key":"herbert@gondor.apana.org.au","avatar":null},"body":"Daniel Barkalow <barkalow@iabervon.org> wrote:\n>\n> -    'test \"$(wc -l full-of-directories | sed -e \"s/ .*//\")\" = 257'\n> +    'test $(cat full-of-directories | wc -l) = 257'\n\nYou don't need the cat:\n\nwc -l < full-of-directories\n\nwill do the same thing.\n\nIt's also better to use -eq instead of = since you are comparing\nnumbers, not strings.  If you do that you can keep the double\nquotes since the spaces will be removed automatically.\n\nCheers,\n-- \nVisit Openswan at http://www.openswan.org/\nEmail: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>\nHome Page: http://gondor.apana.org.au/~herbert/\nPGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt\n"},{"id":"3694","messageId":"7vhdgwj1ed.fsf@assigned-by-dhcp.cox.net","threadId":"680","inReplyTo":"E1DZRMi-00021X-00@gondolin.me.apana.org.au","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-21T10:53:30Z","receivedAt":"2005-05-21T10:53:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"HX\" == Herbert Xu <herbert@gondor.apana.org.au> writes:\n\nHX> It's also better to use -eq instead of = since you are comparing\nHX> numbers, not strings.  If you do that you can keep the double\nHX> quotes since the spaces will be removed automatically.\n\nI remember being burned by busybox \"test\" which did not ignore\nspaces.  I do not know if the latest one is fixed, though.\n\n"},{"id":"3695","messageId":"20050521110129.GA7924@gondor.apana.org.au","threadId":"680","inReplyTo":"7vhdgwj1ed.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Herbert Xu","fromEmail":"herbert@gondor.apana.org.au","sentAt":"2005-05-21T11:01:29Z","receivedAt":"2005-05-21T11:01:29Z","isPatch":true,"sender":{"key":"herbert@gondor.apana.org.au","avatar":null},"body":"On Sat, May 21, 2005 at 03:53:30AM -0700, Junio C Hamano wrote:\n> >>>>> \"HX\" == Herbert Xu <herbert@gondor.apana.org.au> writes:\n> \n> HX> It's also better to use -eq instead of = since you are comparing\n> HX> numbers, not strings.  If you do that you can keep the double\n> HX> quotes since the spaces will be removed automatically.\n> \n> I remember being burned by busybox \"test\" which did not ignore\n> spaces.  I do not know if the latest one is fixed, though.\n\nAre you sure that it didn't ignore the leading spaces with -eq?\nThe code in question just calls strtol.\n\nCheers,\n-- \nVisit Openswan at http://www.openswan.org/\nEmail: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>\nHome Page: http://gondor.apana.org.au/~herbert/\nPGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt\n"},{"id":"3702","messageId":"7vd5rkij9y.fsf@assigned-by-dhcp.cox.net","threadId":"680","inReplyTo":"20050521110129.GA7924@gondor.apana.org.au","subject":"Re: [PATCH] Fix use of wc in t0000-basic","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-21T17:24:57Z","receivedAt":"2005-05-21T17:24:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"HX\" == Herbert Xu <herbert@gondor.apana.org.au> writes:\n\nHX> Are you sure that it didn't ignore the leading spaces with -eq?\nHX> The code in question just calls strtol.\n\nSorry, I am not sure whose fault it was, and the recollection\ncomes from my distant past.  It could have been that the\nsmallish shell in that semi-embedded environment had an\nincompatible built-in \"test\" command which was burning me, but\nI distinctively remember changing many of the vendor supplied\nshell script that had:\n\n    if test \" $number\" -eq 3\n    then\n        ...\n\neither stripping dq around it or simply removing the space from\nthere, depending on how that $number was generated.\n\nSince I assume we are only talking about portability across\nPOSIXy world I do not think this is a big issue.\n\n"}]}