From: Martin Schwenke Date: Wed, 29 Jun 2016 07:54:00 +0000 (+1000) Subject: ctdb-scripts: Use globs instead of ls to list files X-Git-Tag: tdb-1.3.10~485 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=15ed9ad035dd2b4e40c1ce00fe420a6367ef27f1;p=thirdparty%2Fsamba.git ctdb-scripts: Use globs instead of ls to list files shellcheck reports that using ls is fragile. 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 23a88ed4417..92f16339369 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -70,11 +70,10 @@ check_persistent_databases () [ "${CTDB_MAX_PERSISTENT_CHECK_ERRORS:-0}" = "0" ] || return 0 - for _db in $(ls "$_dir/"*.tdb.*[0-9] 2>/dev/null) ; do - check_tdb $_db || { - echo "Persistent database $_db is corrupted! CTDB will not start." - return 1 - } + for _db in "$_dir/"*.tdb.*[0-9] ; do + [ -r "$_db" ] || continue + check_tdb "$_db" || \ + die "Persistent database $_db is corrupted! CTDB will not start." done } @@ -83,8 +82,9 @@ check_non_persistent_databases () _dir="${CTDB_DBDIR:-${CTDB_VARDIR}}" [ -d "$_dir" ] || return 0 - for _db in $(ls "${_dir}/"*.tdb.*[0-9] 2>/dev/null) ; do - check_tdb $_db || { + for _db in "${_dir}/"*.tdb.*[0-9] ; do + [ -r "$_db" ] || continue + check_tdb "$_db" || { _backup="${_db}.$(date +'%Y%m%d.%H%M%S.%N').corrupt" cat <