Skip to content

Commit

Permalink
ctdb-scripts: Use globs instead of ls to list files
Browse files Browse the repository at this point in the history
shellcheck reports that using ls is fragile.

Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
  • Loading branch information
martin-schwenke authored and Amitay Isaacs committed Jul 6, 2016
1 parent c7ed73a commit 15ed9ad
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ctdb/config/events.d/00.ctdb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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 <<EOF
WARNING: database ${_db} is corrupted.
Expand All @@ -96,7 +96,6 @@ EOF
ls -td "${_db}."*".corrupt" |
tail -n +$((${CTDB_MAX_CORRUPT_DB_BACKUPS:-10} + 1)) |
xargs rm -f

}
done
}
Expand Down

0 comments on commit 15ed9ad

Please sign in to comment.