public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* [Bug] bash' read builtin command behaves differently on '\r' (4.3.33)
@ 2015-05-14 19:52 Mikhail Usenko
  2015-05-14 20:00 ` Eric Blake
  2015-09-24 16:55 ` Eric Blake
  0 siblings, 2 replies; 6+ messages in thread
From: Mikhail Usenko @ 2015-05-14 19:52 UTC (permalink / raw)
  To: cygwin


Cygwin version: 2.0.2-1

[linux]$ bash --version
  GNU bash, version 4.3.33(1)-release (i686-redhat-linux-gnu)
[cygwin]$ bash --version
  GNU bash, version 4.3.33(1)-release (x86_64-unknown-cygwin)

Testcase:
[linux]$ echo -ne "\r\n" | { read t; echo "$t"; } | od -A n -t x1
  0d 0a
[cygwin]$ echo -ne "\r\n" | { read t; echo "$t"; } | od -A n -t x1
  0a

But then, the pipe itself is OK:
[cygwin]$ echo -e "\r" | od -A n -t x1
  0d 0a

-- 


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bug] bash' read builtin command behaves differently on '\r' (4.3.33)
  2015-05-14 19:52 [Bug] bash' read builtin command behaves differently on '\r' (4.3.33) Mikhail Usenko
@ 2015-05-14 20:00 ` Eric Blake
  2015-05-14 20:18   ` Mikhail Usenko
  2015-05-14 20:54   ` Mikhail Usenko
  2015-09-24 16:55 ` Eric Blake
  1 sibling, 2 replies; 6+ messages in thread
From: Eric Blake @ 2015-05-14 20:00 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 759 bytes --]

On 05/14/2015 01:32 PM, Mikhail Usenko wrote:
> 
> Cygwin version: 2.0.2-1
> 
> [linux]$ bash --version
>   GNU bash, version 4.3.33(1)-release (i686-redhat-linux-gnu)
> [cygwin]$ bash --version
>   GNU bash, version 4.3.33(1)-release (x86_64-unknown-cygwin)
> 
> Testcase:
> [linux]$ echo -ne "\r\n" | { read t; echo "$t"; } | od -A n -t x1

echo -n is not portable; use printf instead:

printf %s '\r\n'

or with a bash-ism:

printf $'\r\n'

>   0d 0a
> [cygwin]$ echo -ne "\r\n" | { read t; echo "$t"; } | od -A n -t x1
>   0a

Umm, are you sure you haven't turned on the igncr shell option in your
cygwin environment?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bug] bash' read builtin command behaves differently on '\r' (4.3.33)
  2015-05-14 20:00 ` Eric Blake
@ 2015-05-14 20:18   ` Mikhail Usenko
  2015-05-14 20:54   ` Mikhail Usenko
  1 sibling, 0 replies; 6+ messages in thread
From: Mikhail Usenko @ 2015-05-14 20:18 UTC (permalink / raw)
  To: cygwin

On Thu, 14 May 2015 13:53:38 -0600
Eric Blake <...> wrote:

> 
> Umm, are you sure you haven't turned on the igncr shell option in your
> cygwin environment?
> 

$ set -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
igncr           off
ignoreeof       off
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off


-- 


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bug] bash' read builtin command behaves differently on '\r' (4.3.33)
  2015-05-14 20:00 ` Eric Blake
  2015-05-14 20:18   ` Mikhail Usenko
@ 2015-05-14 20:54   ` Mikhail Usenko
  2015-05-14 22:23     ` Eric Blake
  1 sibling, 1 reply; 6+ messages in thread
From: Mikhail Usenko @ 2015-05-14 20:54 UTC (permalink / raw)
  To: cygwin

Also when a bash script is launched from an external program
with connected stdio from/to the program using a UNIX domain
socket generated by socketpair() the read builtin works OK.

-- 


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bug] bash' read builtin command behaves differently on '\r' (4.3.33)
  2015-05-14 20:54   ` Mikhail Usenko
@ 2015-05-14 22:23     ` Eric Blake
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2015-05-14 22:23 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

On 05/14/2015 02:18 PM, Mikhail Usenko wrote:
> Also when a bash script is launched from an external program
> with connected stdio from/to the program using a UNIX domain
> socket generated by socketpair() the read builtin works OK.

Thanks for the additional information. I can indeed duplicate that bash
is stripping \r\n to \n, but NOT stripping other \r, when reading from a
pipe:

$ printf ':\r:\r\n' | { read t; echo "-$t-"; } | od -tx1
0000000 2d 3a 0d 3a 2d 0a
0000006

and pipes themselves are not doing the stripping:

$ printf ':\r:\r\n' | od -tx1
0000000 3a 0d 3a 0d 0a
0000005

I also confirmed that raw files have the same problem.  Possibly a bug I
introduced in my code to support igncr, so I'll try to root it out.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bug] bash' read builtin command behaves differently on '\r' (4.3.33)
  2015-05-14 19:52 [Bug] bash' read builtin command behaves differently on '\r' (4.3.33) Mikhail Usenko
  2015-05-14 20:00 ` Eric Blake
@ 2015-09-24 16:55 ` Eric Blake
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Blake @ 2015-09-24 16:55 UTC (permalink / raw)
  To: cygwin, Jeff Downs

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

On 05/14/2015 01:32 PM, Mikhail Usenko wrote:
> 
> Cygwin version: 2.0.2-1
> 
> [linux]$ bash --version
>   GNU bash, version 4.3.33(1)-release (i686-redhat-linux-gnu)
> [cygwin]$ bash --version
>   GNU bash, version 4.3.33(1)-release (x86_64-unknown-cygwin)
> 
> Testcase:
> [linux]$ echo -ne "\r\n" | { read t; echo "$t"; } | od -A n -t x1
>   0d 0a
> [cygwin]$ echo -ne "\r\n" | { read t; echo "$t"; } | od -A n -t x1
>   0a
> 
> But then, the pipe itself is OK:
> [cygwin]$ echo -e "\r" | od -A n -t x1
>   0d 0a

Jeff Downs helped me investigate off-list, and I think he found the
culprit (a typo in input.c that requested O_TEXT when it meant B_TEXT,
when mapping from open() flags to bash's internal B_* flags). I'm
building a new bash build right now, and will shortly be posting it for
testing.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-24 16:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 19:52 [Bug] bash' read builtin command behaves differently on '\r' (4.3.33) Mikhail Usenko
2015-05-14 20:00 ` Eric Blake
2015-05-14 20:18   ` Mikhail Usenko
2015-05-14 20:54   ` Mikhail Usenko
2015-05-14 22:23     ` Eric Blake
2015-09-24 16:55 ` Eric Blake

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).