{"thread":{"id":"13155","subject":"[BUGS] test failure in t4014-format-patch.sh with master","startedAt":"2008-04-17T09:30:25Z","lastAt":"2008-04-19T06:51:08Z","messageCount":12,"participants":["Remi Vanicat","Linus Torvalds","Björn Steinbrink","Rémi Vanicat","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"74637","messageId":"87od88eslq.dlv@maison.homelinux.org","threadId":"13155","inReplyTo":null,"subject":"[BUGS] test failure in t4014-format-patch.sh with master","fromName":"Remi Vanicat","fromEmail":"vanicat@debian.org","sentAt":"2008-04-17T09:30:25Z","receivedAt":"2008-04-17T09:30:25Z","isPatch":false,"sender":{"key":"vanicat@debian.org","avatar":"https://gravatar.com/avatar/cd491a7f4c221349809a60f88fc21326b97cce2a705e318898aa74851db92409?d=mp&s=160"},"body":"Hello,\n\nWhile trying to wrote a test for git, I discover that there is a test\nfailure in master on my computer:\n\n$ ./t4014-format-patch.sh\n[....]\n* FAIL 8: replay did not screw up the log message\n\n git cat-file commit rebuild-1 | grep \"^Side .* with .* backslash-n\"\n\n\nIt seem that now, somewhere a \\n has been interpreted as a newline.\n\nBisecting point the problem to the 2e6e3e82 commit \"git-am: cope\nbetter with an empty Subject: line\"\n\n\n-- \nRémi Vanicat\n"},{"id":"74641","messageId":"alpine.LFD.1.00.0804170806430.2879@woody.linux-foundation.org","threadId":"13155","inReplyTo":"87od88eslq.dlv@maison.homelinux.org","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-04-17T15:11:52Z","receivedAt":"2008-04-17T15:11:52Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 17 Apr 2008, Remi Vanicat wrote:\n> \n> While trying to wrote a test for git, I discover that there is a test\n> failure in master on my computer:\n\nHmm. Doesn't fail for me.\n\n> $ ./t4014-format-patch.sh\n> [....]\n> * FAIL 8: replay did not screw up the log message\n> \n>  git cat-file commit rebuild-1 | grep \"^Side .* with .* backslash-n\"\n> \n> It seem that now, somewhere a \\n has been interpreted as a newline.\n\nI wonder if it is some shell-specific variable expansion issue. What's \nyour /bin/sh? (I assume, from your email address, that you're using \nDebian, and I thought Debian used bash, but maybe that's not true).\n\nWhat does\n\n\ta=\"hello\\nhi\"\n\techo $a\n\nresult in?\n\n\t\tLinus\n"},{"id":"74645","messageId":"20080417153421.GA13117@atjola.homenet","threadId":"13155","inReplyTo":"alpine.LFD.1.00.0804170806430.2879@woody.linux-foundation.org","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-04-17T15:34:21Z","receivedAt":"2008-04-17T15:34:21Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.04.17 08:11:52 -0700, Linus Torvalds wrote:\n> \n> \n> On Thu, 17 Apr 2008, Remi Vanicat wrote:\n> > \n> > While trying to wrote a test for git, I discover that there is a test\n> > failure in master on my computer:\n> \n> Hmm. Doesn't fail for me.\n> \n> > $ ./t4014-format-patch.sh\n> > [....]\n> > * FAIL 8: replay did not screw up the log message\n> > \n> >  git cat-file commit rebuild-1 | grep \"^Side .* with .* backslash-n\"\n> > \n> > It seem that now, somewhere a \\n has been interpreted as a newline.\n> \n> I wonder if it is some shell-specific variable expansion issue. What's \n> your /bin/sh? (I assume, from your email address, that you're using \n> Debian, and I thought Debian used bash, but maybe that's not true).\n> \n> What does\n> \n> \ta=\"hello\\nhi\"\n> \techo $a\n> \n> result in?\n\nDebian has its own dash which is supposed to be a lightweight\nalternative to bash and \"for checking POSIX compliance of scripts\"\n(quote from the packages description). I don't happen to know off-hand\nwhether POSIX says that echo should default to -e, but dash seems to do\nthat:\n\n$ dash\n$ a=\"hello\\nhi\"\n$ echo $a\nhello\nhi\n\nBjörn\n"},{"id":"74646","messageId":"6b8a91420804170844t2776e8a7sf735e3f87a95298b@mail.gmail.com","threadId":"13155","inReplyTo":"alpine.LFD.1.00.0804170806430.2879@woody.linux-foundation.org","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Rémi Vanicat","fromEmail":"vanicat@debian.org","sentAt":"2008-04-17T15:44:05Z","receivedAt":"2008-04-17T15:44:05Z","isPatch":false,"sender":{"key":"vanicat@debian.org","avatar":"https://gravatar.com/avatar/cd491a7f4c221349809a60f88fc21326b97cce2a705e318898aa74851db92409?d=mp&s=160"},"body":"2008/4/17, Linus Torvalds <torvalds@linux-foundation.org>:\n>\n>\n>  On Thu, 17 Apr 2008, Remi Vanicat wrote:\n[...]\n>  > $ ./t4014-format-patch.sh\n>  > [....]\n>  > * FAIL 8: replay did not screw up the log message\n>\n>  Hmm. Doesn't fail for me.\n\n[...]\n\n>  I wonder if it is some shell-specific variable expansion issue. What's\n>  your /bin/sh? (I assume, from your email address, that you're using\n>  Debian, and I thought Debian used bash, but maybe that's not true).\n\nDebian used bash, but I use dash as /bin/sh\n\n>  What does\n>\n>         a=\"hello\\nhi\"\n>         echo $a\n>\n>  result in?\n\nhere is the problem:\n\n$/bin/sh\n$ a=\"hello\\nhi\"\n$ echo $a\nhello\nhi\n\nMmm, I Wonder what posix said about this, but it look like a bug with dash\n"},{"id":"74643","messageId":"alpine.LFD.1.00.0804170841270.2879@woody.linux-foundation.org","threadId":"13155","inReplyTo":"20080417153421.GA13117@atjola.homenet","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-04-17T15:44:07Z","receivedAt":"2008-04-17T15:44:07Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 17 Apr 2008, Björn Steinbrink wrote:\n> \n> Debian has its own dash which is supposed to be a lightweight\n> alternative to bash and \"for checking POSIX compliance of scripts\"\n> (quote from the packages description). I don't happen to know off-hand\n> whether POSIX says that echo should default to -e, but dash seems to do\n> that:\n> \n> $ dash\n> $ a=\"hello\\nhi\"\n> $ echo $a\n> hello\n> hi\n\nAhh. So that \"echo\" should just be replaced with a 'printf \"%s\\n\"' \ninstead? \n\nWe have a _lot_ of \"echo\"s though. I suspect the only ones we'd ever catch \nare the ones explicitly tested for. I suspect that the dash echo is just \nbroken.\n\n\t\tLinus\n"},{"id":"74647","messageId":"20080417160327.GA13462@atjola.homenet","threadId":"13155","inReplyTo":"alpine.LFD.1.00.0804170841270.2879@woody.linux-foundation.org","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-04-17T16:03:27Z","receivedAt":"2008-04-17T16:03:27Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.04.17 08:44:07 -0700, Linus Torvalds wrote:\n> \n> \n> On Thu, 17 Apr 2008, Björn Steinbrink wrote:\n> > \n> > Debian has its own dash which is supposed to be a lightweight\n> > alternative to bash and \"for checking POSIX compliance of scripts\"\n> > (quote from the packages description). I don't happen to know off-hand\n> > whether POSIX says that echo should default to -e, but dash seems to do\n> > that:\n> > \n> > $ dash\n> > $ a=\"hello\\nhi\"\n> > $ echo $a\n> > hello\n> > hi\n> \n> Ahh. So that \"echo\" should just be replaced with a 'printf \"%s\\n\"' \n> instead? \n> \n> We have a _lot_ of \"echo\"s though. I suspect the only ones we'd ever catch \n> are the ones explicitly tested for. I suspect that the dash echo is just \n> broken.\n\nWow, seems that \"echo\" in itself is \"broken\". According to POSIX[1]\nbackslashes induce implementation defined behaviour, and there seem to\nbe two historic versions of echo, one that knows about -n and one that\ninterprets escape sequences. So echo is totally non-portable unless you\navoid -n as well as backslashes. Ouch.\n\nThe POSIX docs, as well as random Google results, indeed recommend to\nuse printf instead. But that switch seems painful as well...\n\nBjörn\n\n[1] http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html\n"},{"id":"74650","messageId":"20080417162421.GA18318@sigill.intra.peff.net","threadId":"13155","inReplyTo":"alpine.LFD.1.00.0804170841270.2879@woody.linux-foundation.org","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-04-17T16:24:22Z","receivedAt":"2008-04-17T16:24:22Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Apr 17, 2008 at 08:44:07AM -0700, Linus Torvalds wrote:\n\n> Ahh. So that \"echo\" should just be replaced with a 'printf \"%s\\n\"' \n> instead? \n> \n> We have a _lot_ of \"echo\"s though. I suspect the only ones we'd ever catch \n> are the ones explicitly tested for. I suspect that the dash echo is just \n> broken.\n\nAs Bjorn mentioned, it's POSIX.  Junio and I already hunted down quite a\nfew of these, so I think we are OK in general, and this is just a new\none that got introduced.\n\n-Peff\n"},{"id":"74648","messageId":"20080417162700.GB18318@sigill.intra.peff.net","threadId":"13155","inReplyTo":"20080417162421.GA18318@sigill.intra.peff.net","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-04-17T16:27:00Z","receivedAt":"2008-04-17T16:27:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Apr 17, 2008 at 12:24:22PM -0400, Jeff King wrote:\n\n> As Bjorn mentioned, it's POSIX.  Junio and I already hunted down quite a\n> few of these, so I think we are OK in general, and this is just a new\n> one that got introduced.\n\nOops, I meant to mention this thread:\n\n  http://article.gmane.org/gmane.comp.version-control.git/48419\n\n-Peff\n"},{"id":"74724","messageId":"7vskxjj9rb.fsf@gitster.siamese.dyndns.org","threadId":"13155","inReplyTo":"6b8a91420804170844t2776e8a7sf735e3f87a95298b@mail.gmail.com","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-18T18:30:48Z","receivedAt":"2008-04-18T18:30:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Rémi Vanicat\" <vanicat@debian.org> writes:\n\n> 2008/4/17, Linus Torvalds <torvalds@linux-foundation.org>:\n>>\n>>  On Thu, 17 Apr 2008, Remi Vanicat wrote:\n> [...]\n>>  > $ ./t4014-format-patch.sh\n>>  > [....]\n>>  > * FAIL 8: replay did not screw up the log message\n>>\n>>  Hmm. Doesn't fail for me.\n>\n> [...]\n>\n>>  I wonder if it is some shell-specific variable expansion issue. What's\n>>  your /bin/sh? (I assume, from your email address, that you're using\n>>  Debian, and I thought Debian used bash, but maybe that's not true).\n>\n> Debian used bash, but I use dash as /bin/sh\n>\n>>  What does\n>>\n>>         a=\"hello\\nhi\"\n>>         echo $a\n>>\n>>  result in?\n\nSo perhaps this one is the troublemaker?\n\n git-am.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 646dc45..5b20bbd 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -330,7 +330,7 @@ do\n \t\tSUBJECT=\"$(sed -n '/^Subject/ s/Subject: //p' \"$dotest/info\")\"\n \t\tcase \"$keep_subject\" in -k)  SUBJECT=\"[PATCH] $SUBJECT\" ;; esac\n \n-\t\t(echo \"$SUBJECT\" ; echo ; cat \"$dotest/msg\") |\n+\t\t(printf '%s\\n' \"$SUBJECT\" ; echo ; cat \"$dotest/msg\") |\n \t\t\tgit stripspace > \"$dotest/msg-clean\"\n \t\t;;\n \tesac\n"},{"id":"74723","messageId":"alpine.LFD.1.10.0804181135540.2779@woody.linux-foundation.org","threadId":"13155","inReplyTo":"7vskxjj9rb.fsf@gitster.siamese.dyndns.org","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-04-18T18:37:25Z","receivedAt":"2008-04-18T18:37:25Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 18 Apr 2008, Junio C Hamano wrote:\n>\n> -\t\t(echo \"$SUBJECT\" ; echo ; cat \"$dotest/msg\") |\n> +\t\t(printf '%s\\n' \"$SUBJECT\" ; echo ; cat \"$dotest/msg\") |\n\nWell, get rid of the superfluous second 'echo' then too, replacing it \nwith another '\\n'. IOW:\n\n\t( printf '%s\\n\\n' \"$SUBJECT\" ; cat \"$dotest/msg\" ) | \n\ninstead.\n\n\t\tLinus\n"},{"id":"74720","messageId":"6b8a91420804181513m139baf06x41d8efeb7acd49a3@mail.gmail.com","threadId":"13155","inReplyTo":"alpine.LFD.1.10.0804181135540.2779@woody.linux-foundation.org","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Rémi Vanicat","fromEmail":"vanicat@debian.org","sentAt":"2008-04-18T22:13:50Z","receivedAt":"2008-04-18T22:13:50Z","isPatch":false,"sender":{"key":"vanicat@debian.org","avatar":"https://gravatar.com/avatar/cd491a7f4c221349809a60f88fc21326b97cce2a705e318898aa74851db92409?d=mp&s=160"},"body":"2008/4/18, Linus Torvalds <torvalds@linux-foundation.org>:\n>\n>\n>  On Fri, 18 Apr 2008, Junio C Hamano wrote:\n>  >\n>  > -             (echo \"$SUBJECT\" ; echo ; cat \"$dotest/msg\") |\n>  > +             (printf '%s\\n' \"$SUBJECT\" ; echo ; cat \"$dotest/msg\") |\n>\n>\n> Well, get rid of the superfluous second 'echo' then too, replacing it\n>  with another '\\n'. IOW:\n>\n>         ( printf '%s\\n\\n' \"$SUBJECT\" ; cat \"$dotest/msg\" ) |\n>\n>  instead.\n\nThis work for me: no more test failure on my computer\n"},{"id":"74742","messageId":"7vfxtiibhf.fsf@gitster.siamese.dyndns.org","threadId":"13155","inReplyTo":"6b8a91420804181513m139baf06x41d8efeb7acd49a3@mail.gmail.com","subject":"Re: [BUGS] test failure in t4014-format-patch.sh with master","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-19T06:51:08Z","receivedAt":"2008-04-19T06:51:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Rémi Vanicat\" <vanicat@debian.org> writes:\n\n> 2008/4/18, Linus Torvalds <torvalds@linux-foundation.org>:\n>>\n>>\n>>  On Fri, 18 Apr 2008, Junio C Hamano wrote:\n>>  >\n>>  > -             (echo \"$SUBJECT\" ; echo ; cat \"$dotest/msg\") |\n>>  > +             (printf '%s\\n' \"$SUBJECT\" ; echo ; cat \"$dotest/msg\") |\n>>\n>>\n>> Well, get rid of the superfluous second 'echo' then too, replacing it\n>>  with another '\\n'. IOW:\n>>\n>>         ( printf '%s\\n\\n' \"$SUBJECT\" ; cat \"$dotest/msg\" ) |\n>>\n>>  instead.\n>\n> This work for me: no more test failure on my computer\n\nThanks for confirmation.  I reproduced the breakage and the fix myself\nwith \"make SHELL_PATH=/bin/dash\" myself, too.\n"}]}