This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ANNOUNCEMENT] Updated: bash-4.3.42-3


On Tue, 25 Aug 2015 14:19:54 -0600
Eric Blake (cygwin) <...> wrote:

> A new release of bash, 4.3.42-3, has been uploaded and will soon reach a
> mirror near you; leaving 4.3.39-2 as the previous version.
> 

It is one more buggy release (cygwin-specific).

---8<---(cygwin-test.sh)---8<---
#! /bin/bash

sender()
{
  echo -n  '\r\n' >&2
  echo -ne '\r\n'
  sleep 1
  echo -n  '\r\r\n' >&2
  echo -ne '\r\r\n'
  sleep 1
  echo -n  '\r\r\r\n' >&2
  echo -ne '\r\r\r\n'
  sleep 1
}

receiver()
{
  t=""
  while read t || [ "$t" ]; do
    echo -n ": "
    od -A n -t x1  <<<"$t"
  done  >&2
}

# implicit pipe
receiver < <(sender)

# explicit pipeline
sender | receiver

--->8---(cygwin-test.sh)--->8---

$ ./cygwin-test.sh
\r\n:  0a
\r\r\n:  0d 0d 0a
\r\r\r\n:  0d 0d 0a
\r\n:  0a
\r\r\n:  0d 0d 0a
\r\r\r\n:  0d 0d 0a

There is also the similar problem found accidentally just now with sed in pipelines:
$ echo -ne "\r\n" | sed '' | od -A n -tx1  # should be: 0d 0a
 0a
$ echo -ne "\r\r\n" | sed '' | od -A n -tx1  # should be: 0d 0d 0a
 0d 0a


On Thu, 04 Jun 2015 06:16:04 -0600
Eric Blake <...> wrote:

> 
> 'echo -ne' is non-portable (I can break it with 'shopt -s xpg_echo');
> get used to using 'printf' instead.
> 

xpg_echo doesn't change 'echo -ne' behavior
('echo -e' force backslash-escape sequences expansion independently)

$ shopt xpg_echo
xpg_echo        off
$ echo -e '\r\n' | od -tx1
0000000 0d 0a 0a
0000003
$ shopt -s xpg_echo
$ shopt xpg_echo
xpg_echo        on
$ echo -e '\r\n' | od -tx1
0000000 0d 0a 0a
0000003
$ echo '\r\n' | od -tx1
0000000 0d 0a 0a
0000003


-- 
Mike


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]