From: Martin Schwenke Date: Tue, 12 Jul 2016 20:53:21 +0000 (+1000) Subject: ctdb-scripts: Avoid shellcheck warning SC2012 (ls for file list) X-Git-Tag: tdb-1.3.10~258 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=52b43d73e9fb925757d7a033b74c9c74bbcc7d32;p=thirdparty%2Fsamba.git ctdb-scripts: Avoid shellcheck warning SC2012 (ls for file list) SC2012: Use find instead of ls to better handle non-alphanumeric filenames. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb index 3649ed001d6..d60b9aa53c3 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -93,9 +93,12 @@ EOF mv "$_db" "$_backup" # Now remove excess backups - ls -td "${_db}."*".corrupt" | - tail -n +$((${CTDB_MAX_CORRUPT_DB_BACKUPS:-10} + 1)) | - xargs rm -f + _max="${CTDB_MAX_CORRUPT_DB_BACKUPS:-10}" + _bdb="${_db##*/}" # basename + find "$_dir" -name "${_bdb}.*.corrupt" | + sort -r | + tail -n +$((_max + 1)) | + xargs rm -f } done }