Package: automysqlbackup
Version: 2.6+debian-2
Severity: minor

The default configuration example of

    DBNAMES=`mysql --defaults-file=/etc/mysql/debian.cnf --execute="SHOW
DATABASES" | awk '{print $1}' | grep -v ^Database$ | grep -v ^mysql$ | tr
\\\r\\\n ,\ `

can be done tidier in a single text processing fork as e.g.

    DBNAMES=$(mysql --defaults-file=/etc/mysql/debian.cnf --execute="SHOW
DATABASES" | awk 'BEGIN{ORS=" "}!/^(Database|mysql)$/')

which also leaves line ending peculiarities to a more agnostic awk handling.

grep-like matching is built in to awk. Since the mysql output is not fancy
formatted when redirected, the `^$` pattern matches correctly (and the earlier
`awk '{print $1}'` fork actually does nothing at all from what I can tell).

`print` is default action, so just setting output record separator to blank
space is equivalent to the `tr` command.

This is still POSIX compatible (testable with `-c`).

Somewhat similarly, the other example

    DBNAMES=`find /var/lib/mysql -mindepth 1 -maxdepth 1 -type d | cut -d'/'
-f5 | grep -v ^mysql\$ | tr \\\r\\\n ,\ `

can be done as e.g.

    DBNAMES=$(ls -d /var/lib/mysql/*/ | awk -F/ 'BEGIN{ORS="
"}$5!="mysql"{print $5}')

or in a single command assuming GNU find (with the `-printf` option)

    DBNAMES=$(find /var/lib/mysql -mindepth 1 -maxdepth 1 -type d -not -name
'mysql' -printf '%f ')

The `\\\r` -> `,` translation actually also does nothing on my system in either
case.

Ridiculously low-priority of course, but since I'm procrastinating... :-)



-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-2-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages automysqlbackup depends on:
ii  mysql-client                     5.5.23-2
ii  mysql-client-5.5 [mysql-client]  5.5.23-2

Versions of packages automysqlbackup recommends:
ii  mutt  1.5.21-5+b1

automysqlbackup suggests no packages.

-- Configuration Files:
/etc/default/automysqlbackup changed [not included]

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to