public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: cygwin@cygwin.com
Subject: Re: Script broken after updating bash to 4.3.46-7?
Date: Tue, 30 Aug 2016 03:21:00 -0000	[thread overview]
Message-ID: <93be816b-952c-20cd-575e-940cdf4fbbd1@redhat.com> (raw)
In-Reply-To: <CAPTiy3PW0+bk20d30-J=sLr=PPnFOeU0Fb495hh1bBVtbtPrzw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1397 bytes --]

On 08/26/2016 06:49 PM, Gene Pavlovsky wrote:
> After I updated Cygwin yesterday, a daily database backup bash script
> (`automysqlbackup`) broke.
> My previous bash was 4.3.42-4 (installed when I updated Cygwin on
> 2016/07/23), current is 4.3.46-7.
> Here's the code snippet:
> ```bash
>   local i;i=0;
>   while read -r; do alldbnames[i++]="$REPLY"; done < <(mysql
> --user="${CONFIG_mysql_dump_username}"
> --password="${CONFIG_mysql_dump_password}"
> --host="${CONFIG_mysql_dump_host}" "${mysql_opt[@]}" --batch
> --skip-column-names -e "show databases")
> ```
> This is supposed to get the list of all databases. Before it worked.

By pure luck.  The 'read' builtin was inconsistent on cygwin, in that it
FORCED people to use text mode (and ate \r before \n), even when they
wanted pure binary input, which was different than all other aspects of
bash; and worse had a bug where \r before something else would cause the
something else to be incorrectly eaten.

> Now every item on the list ends with the CR character ($'\r'), causing
> a bunch of issues with further script opreation. I'm using official
> MariaDB Windows x64 binaries.

Simplest fix:

read ... < <(mysql ... | dos2unix)

There. Now you aren't feeding \r to read in the first place.

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

  parent reply	other threads:[~2016-08-29 18:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-27 10:28 Gene Pavlovsky
2016-08-27 11:25 ` Gene Pavlovsky
2016-08-27 17:24   ` Andrey Repin
2016-08-28 10:19     ` Gene Pavlovsky
2016-08-29 13:28       ` Nellis, Kenneth
2016-08-29 14:05     ` cyg Simple
2016-08-30  3:21 ` Eric Blake [this message]
2016-08-30 18:21   ` cyg Simple
2016-08-30 18:32     ` Eric Blake
2016-08-31 10:16       ` cyg Simple
2016-09-04  9:38         ` Gene Pavlovsky
2016-09-04 17:37           ` Lee
2016-09-05 23:37             ` Gene Pavlovsky
2016-09-06 13:15           ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93be816b-952c-20cd-575e-940cdf4fbbd1@redhat.com \
    --to=eblake@redhat.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).