bug-patch
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-patch] patch 2.7.1 tests fail when $(SHELL) is not bash or bash


From: Harald van Dijk
Subject: Re: [bug-patch] patch 2.7.1 tests fail when $(SHELL) is not bash or bash-like
Date: Tue, 13 Nov 2012 21:27:51 +0100
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:16.0) Gecko/20121104 Thunderbird/16.0.2

On 11/13/2012 09:09 PM, Mike Frysinger wrote:
> On Tuesday 13 November 2012 13:17:40 Harald van Dijk wrote:
>> Secondly, echo -e is nonportable (see `man 1p echo` on most Linux
>> systems), and doesn't behave on dash as it does on bash, causing a test
>> failure in crlf-handling.
>>
>> --- patch-2.7.1/tests/crlf-handling
>> +++ patch-2.7.1/tests/crlf-handling
>> @@ -14,7 +14,7 @@
>>  use_tmpdir
>>
>>  lf2crlf() {
>> -    while read l; do echo -e "$l\r"; done
>> +    while read l; do printf "%s\r\n" "$l"; done
>>  }
>>
>>  echo 1 > a
>>
>> printf is valid POSIX sh, which is what I've replaced it with, but I
>> don't know how portable it is to not-quite-POSIX shells that you may
>> wish to support.
> i don't think those statements are equivalent.  you probably want to use %b 
> instead of %s.
Generally speaking, you're right, as %b supports escape sequences, while
%s does not. echo here is passed the -e option, so would check for
escape sequences in $l (when using bash's echo). However, the only
reason for the -e option is to turn \r into CR, there are no backslashes
anywhere else.
> printf should be portable to any semi-relevant system (and more).
> -mike
Cheers,
Harald



reply via email to

[Prev in Thread] Current Thread [Next in Thread]