From 15ed9ad035dd2b4e40c1ce00fe420a6367ef27f1 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 29 Jun 2016 17:54:00 +1000 Subject: [PATCH] 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 --- ctdb/config/events.d/00.ctdb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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 <