* [BUGS] test failure in t4014-format-patch.sh with master
@ 2008-04-17 9:30 Remi Vanicat
2008-04-17 15:11 ` Linus Torvalds
0 siblings, 1 reply; 12+ messages in thread
From: Remi Vanicat @ 2008-04-17 9:30 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds, Junio C Hamano
Hello,
While trying to wrote a test for git, I discover that there is a test
failure in master on my computer:
$ ./t4014-format-patch.sh
[....]
* FAIL 8: replay did not screw up the log message
git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
It seem that now, somewhere a \n has been interpreted as a newline.
Bisecting point the problem to the 2e6e3e82 commit "git-am: cope
better with an empty Subject: line"
--
Rémi Vanicat
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-17 9:30 [BUGS] test failure in t4014-format-patch.sh with master Remi Vanicat
@ 2008-04-17 15:11 ` Linus Torvalds
2008-04-17 15:34 ` Björn Steinbrink
2008-04-17 15:44 ` Rémi Vanicat
0 siblings, 2 replies; 12+ messages in thread
From: Linus Torvalds @ 2008-04-17 15:11 UTC (permalink / raw)
To: Remi Vanicat; +Cc: git, Junio C Hamano
On Thu, 17 Apr 2008, Remi Vanicat wrote:
>
> While trying to wrote a test for git, I discover that there is a test
> failure in master on my computer:
Hmm. Doesn't fail for me.
> $ ./t4014-format-patch.sh
> [....]
> * FAIL 8: replay did not screw up the log message
>
> git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
>
> It seem that now, somewhere a \n has been interpreted as a newline.
I wonder if it is some shell-specific variable expansion issue. What's
your /bin/sh? (I assume, from your email address, that you're using
Debian, and I thought Debian used bash, but maybe that's not true).
What does
a="hello\nhi"
echo $a
result in?
Linus
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-17 15:11 ` Linus Torvalds
@ 2008-04-17 15:34 ` Björn Steinbrink
2008-04-17 15:44 ` Linus Torvalds
2008-04-17 15:44 ` Rémi Vanicat
1 sibling, 1 reply; 12+ messages in thread
From: Björn Steinbrink @ 2008-04-17 15:34 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Remi Vanicat, git, Junio C Hamano
On 2008.04.17 08:11:52 -0700, Linus Torvalds wrote:
>
>
> On Thu, 17 Apr 2008, Remi Vanicat wrote:
> >
> > While trying to wrote a test for git, I discover that there is a test
> > failure in master on my computer:
>
> Hmm. Doesn't fail for me.
>
> > $ ./t4014-format-patch.sh
> > [....]
> > * FAIL 8: replay did not screw up the log message
> >
> > git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
> >
> > It seem that now, somewhere a \n has been interpreted as a newline.
>
> I wonder if it is some shell-specific variable expansion issue. What's
> your /bin/sh? (I assume, from your email address, that you're using
> Debian, and I thought Debian used bash, but maybe that's not true).
>
> What does
>
> a="hello\nhi"
> echo $a
>
> result in?
Debian has its own dash which is supposed to be a lightweight
alternative to bash and "for checking POSIX compliance of scripts"
(quote from the packages description). I don't happen to know off-hand
whether POSIX says that echo should default to -e, but dash seems to do
that:
$ dash
$ a="hello\nhi"
$ echo $a
hello
hi
Björn
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-17 15:11 ` Linus Torvalds
2008-04-17 15:34 ` Björn Steinbrink
@ 2008-04-17 15:44 ` Rémi Vanicat
2008-04-18 18:30 ` Junio C Hamano
1 sibling, 1 reply; 12+ messages in thread
From: Rémi Vanicat @ 2008-04-17 15:44 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git, Junio C Hamano
2008/4/17, Linus Torvalds <torvalds@linux-foundation.org>:
>
>
> On Thu, 17 Apr 2008, Remi Vanicat wrote:
[...]
> > $ ./t4014-format-patch.sh
> > [....]
> > * FAIL 8: replay did not screw up the log message
>
> Hmm. Doesn't fail for me.
[...]
> I wonder if it is some shell-specific variable expansion issue. What's
> your /bin/sh? (I assume, from your email address, that you're using
> Debian, and I thought Debian used bash, but maybe that's not true).
Debian used bash, but I use dash as /bin/sh
> What does
>
> a="hello\nhi"
> echo $a
>
> result in?
here is the problem:
$/bin/sh
$ a="hello\nhi"
$ echo $a
hello
hi
Mmm, I Wonder what posix said about this, but it look like a bug with dash
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-17 15:34 ` Björn Steinbrink
@ 2008-04-17 15:44 ` Linus Torvalds
2008-04-17 16:03 ` Björn Steinbrink
2008-04-17 16:24 ` Jeff King
0 siblings, 2 replies; 12+ messages in thread
From: Linus Torvalds @ 2008-04-17 15:44 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: Remi Vanicat, git, Junio C Hamano
On Thu, 17 Apr 2008, Björn Steinbrink wrote:
>
> Debian has its own dash which is supposed to be a lightweight
> alternative to bash and "for checking POSIX compliance of scripts"
> (quote from the packages description). I don't happen to know off-hand
> whether POSIX says that echo should default to -e, but dash seems to do
> that:
>
> $ dash
> $ a="hello\nhi"
> $ echo $a
> hello
> hi
Ahh. So that "echo" should just be replaced with a 'printf "%s\n"'
instead?
We have a _lot_ of "echo"s though. I suspect the only ones we'd ever catch
are the ones explicitly tested for. I suspect that the dash echo is just
broken.
Linus
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-17 15:44 ` Linus Torvalds
@ 2008-04-17 16:03 ` Björn Steinbrink
2008-04-17 16:24 ` Jeff King
1 sibling, 0 replies; 12+ messages in thread
From: Björn Steinbrink @ 2008-04-17 16:03 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Remi Vanicat, git, Junio C Hamano
On 2008.04.17 08:44:07 -0700, Linus Torvalds wrote:
>
>
> On Thu, 17 Apr 2008, Björn Steinbrink wrote:
> >
> > Debian has its own dash which is supposed to be a lightweight
> > alternative to bash and "for checking POSIX compliance of scripts"
> > (quote from the packages description). I don't happen to know off-hand
> > whether POSIX says that echo should default to -e, but dash seems to do
> > that:
> >
> > $ dash
> > $ a="hello\nhi"
> > $ echo $a
> > hello
> > hi
>
> Ahh. So that "echo" should just be replaced with a 'printf "%s\n"'
> instead?
>
> We have a _lot_ of "echo"s though. I suspect the only ones we'd ever catch
> are the ones explicitly tested for. I suspect that the dash echo is just
> broken.
Wow, seems that "echo" in itself is "broken". According to POSIX[1]
backslashes induce implementation defined behaviour, and there seem to
be two historic versions of echo, one that knows about -n and one that
interprets escape sequences. So echo is totally non-portable unless you
avoid -n as well as backslashes. Ouch.
The POSIX docs, as well as random Google results, indeed recommend to
use printf instead. But that switch seems painful as well...
Björn
[1] http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-17 15:44 ` Linus Torvalds
2008-04-17 16:03 ` Björn Steinbrink
@ 2008-04-17 16:24 ` Jeff King
2008-04-17 16:27 ` Jeff King
1 sibling, 1 reply; 12+ messages in thread
From: Jeff King @ 2008-04-17 16:24 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Björn Steinbrink, Remi Vanicat, git, Junio C Hamano
On Thu, Apr 17, 2008 at 08:44:07AM -0700, Linus Torvalds wrote:
> Ahh. So that "echo" should just be replaced with a 'printf "%s\n"'
> instead?
>
> We have a _lot_ of "echo"s though. I suspect the only ones we'd ever catch
> are the ones explicitly tested for. I suspect that the dash echo is just
> broken.
As Bjorn mentioned, it's POSIX. Junio and I already hunted down quite a
few of these, so I think we are OK in general, and this is just a new
one that got introduced.
-Peff
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-17 16:24 ` Jeff King
@ 2008-04-17 16:27 ` Jeff King
0 siblings, 0 replies; 12+ messages in thread
From: Jeff King @ 2008-04-17 16:27 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Björn Steinbrink, Remi Vanicat, git, Junio C Hamano
On Thu, Apr 17, 2008 at 12:24:22PM -0400, Jeff King wrote:
> As Bjorn mentioned, it's POSIX. Junio and I already hunted down quite a
> few of these, so I think we are OK in general, and this is just a new
> one that got introduced.
Oops, I meant to mention this thread:
http://article.gmane.org/gmane.comp.version-control.git/48419
-Peff
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-17 15:44 ` Rémi Vanicat
@ 2008-04-18 18:30 ` Junio C Hamano
2008-04-18 18:37 ` Linus Torvalds
0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2008-04-18 18:30 UTC (permalink / raw)
To: Rémi Vanicat; +Cc: Linus Torvalds, git, Junio C Hamano
"Rémi Vanicat" <vanicat@debian.org> writes:
> 2008/4/17, Linus Torvalds <torvalds@linux-foundation.org>:
>>
>> On Thu, 17 Apr 2008, Remi Vanicat wrote:
> [...]
>> > $ ./t4014-format-patch.sh
>> > [....]
>> > * FAIL 8: replay did not screw up the log message
>>
>> Hmm. Doesn't fail for me.
>
> [...]
>
>> I wonder if it is some shell-specific variable expansion issue. What's
>> your /bin/sh? (I assume, from your email address, that you're using
>> Debian, and I thought Debian used bash, but maybe that's not true).
>
> Debian used bash, but I use dash as /bin/sh
>
>> What does
>>
>> a="hello\nhi"
>> echo $a
>>
>> result in?
So perhaps this one is the troublemaker?
git-am.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index 646dc45..5b20bbd 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -330,7 +330,7 @@ do
SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac
- (echo "$SUBJECT" ; echo ; cat "$dotest/msg") |
+ (printf '%s\n' "$SUBJECT" ; echo ; cat "$dotest/msg") |
git stripspace > "$dotest/msg-clean"
;;
esac
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-18 18:30 ` Junio C Hamano
@ 2008-04-18 18:37 ` Linus Torvalds
2008-04-18 22:13 ` Rémi Vanicat
0 siblings, 1 reply; 12+ messages in thread
From: Linus Torvalds @ 2008-04-18 18:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Rémi Vanicat, git
On Fri, 18 Apr 2008, Junio C Hamano wrote:
>
> - (echo "$SUBJECT" ; echo ; cat "$dotest/msg") |
> + (printf '%s\n' "$SUBJECT" ; echo ; cat "$dotest/msg") |
Well, get rid of the superfluous second 'echo' then too, replacing it
with another '\n'. IOW:
( printf '%s\n\n' "$SUBJECT" ; cat "$dotest/msg" ) |
instead.
Linus
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-18 18:37 ` Linus Torvalds
@ 2008-04-18 22:13 ` Rémi Vanicat
2008-04-19 6:51 ` Junio C Hamano
0 siblings, 1 reply; 12+ messages in thread
From: Rémi Vanicat @ 2008-04-18 22:13 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Junio C Hamano, git
2008/4/18, Linus Torvalds <torvalds@linux-foundation.org>:
>
>
> On Fri, 18 Apr 2008, Junio C Hamano wrote:
> >
> > - (echo "$SUBJECT" ; echo ; cat "$dotest/msg") |
> > + (printf '%s\n' "$SUBJECT" ; echo ; cat "$dotest/msg") |
>
>
> Well, get rid of the superfluous second 'echo' then too, replacing it
> with another '\n'. IOW:
>
> ( printf '%s\n\n' "$SUBJECT" ; cat "$dotest/msg" ) |
>
> instead.
This work for me: no more test failure on my computer
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [BUGS] test failure in t4014-format-patch.sh with master
2008-04-18 22:13 ` Rémi Vanicat
@ 2008-04-19 6:51 ` Junio C Hamano
0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2008-04-19 6:51 UTC (permalink / raw)
To: Rémi Vanicat; +Cc: Linus Torvalds, Junio C Hamano, git
"Rémi Vanicat" <vanicat@debian.org> writes:
> 2008/4/18, Linus Torvalds <torvalds@linux-foundation.org>:
>>
>>
>> On Fri, 18 Apr 2008, Junio C Hamano wrote:
>> >
>> > - (echo "$SUBJECT" ; echo ; cat "$dotest/msg") |
>> > + (printf '%s\n' "$SUBJECT" ; echo ; cat "$dotest/msg") |
>>
>>
>> Well, get rid of the superfluous second 'echo' then too, replacing it
>> with another '\n'. IOW:
>>
>> ( printf '%s\n\n' "$SUBJECT" ; cat "$dotest/msg" ) |
>>
>> instead.
>
> This work for me: no more test failure on my computer
Thanks for confirmation. I reproduced the breakage and the fix myself
with "make SHELL_PATH=/bin/dash" myself, too.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-04-19 6:52 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-17 9:30 [BUGS] test failure in t4014-format-patch.sh with master Remi Vanicat
2008-04-17 15:11 ` Linus Torvalds
2008-04-17 15:34 ` Björn Steinbrink
2008-04-17 15:44 ` Linus Torvalds
2008-04-17 16:03 ` Björn Steinbrink
2008-04-17 16:24 ` Jeff King
2008-04-17 16:27 ` Jeff King
2008-04-17 15:44 ` Rémi Vanicat
2008-04-18 18:30 ` Junio C Hamano
2008-04-18 18:37 ` Linus Torvalds
2008-04-18 22:13 ` Rémi Vanicat
2008-04-19 6:51 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).