1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

ctdb-scripts: Avoid chellcheck warning SC2012 (ls for file list)

SC2012: Use find instead of ls to better handle non-alphanumeric filenames.

Make this cope better with unexpected whitespace.

Unfortunately, this results in shellcheck warning:

  SC2035: Use ./*.tdb.* so names with dashes won't become options.

No!  Then stat(1) will print ./file.tdb.X.  We want the basenames and
we know the filenames don't start with dashes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2016-07-13 11:50:58 +10:00 committed by Amitay Isaacs
parent 52b43d73e9
commit 8bd2c55f98

View File

@ -24,11 +24,13 @@ loadconfig ctdb
echo "===== Start of debug locks PID=$$ ====="
# Create sed expression to convert inodes to names
sed_cmd=$( ls -li "$CTDB_DBDIR"/*.tdb.* "$CTDB_DBDIR_PERSISTENT"/*.tdb.* |
sed -e "s#${CTDB_DBDIR}/\(.*\)#\1#" \
-e "s#${CTDB_DBDIR_PERSISTENT}/\(.*\)#\1#" |
awk '{printf "s#[0-9a-f]*:[0-9a-f]*:%s #%s #\n", $1, $10}' )
# Create sed expression to convert inodes to names.
# Filenames don't contain dashes and we want basenames
# shellcheck disable=SC2035
sed_cmd=$(cd "$CTDB_DBDIR" &&
stat -c "s#[0-9a-f]*:[0-9a-f]*:%i #%n #" *.tdb.* 2>/dev/null ;
cd "$CTDB_DBDIR_PERSISTENT" &&
stat -c "s#[0-9a-f]*:[0-9a-f]*:%i #%n #" *.tdb.* 2>/dev/null)
# Parse /proc/locks and extract following information
# pid process_name tdb_name offsets [W]