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
signature.asc
Description: OpenPGP digital signature