From: Martin Schwenke Date: Wed, 13 Jul 2016 01:50:58 +0000 (+1000) Subject: ctdb-scripts: Avoid chellcheck warning SC2012 (ls for file list) X-Git-Tag: tdb-1.3.10~257 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8bd2c55f98e3fe337d762e01974f877b885fd8ab;p=thirdparty%2Fsamba.git 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/debug_locks.sh b/ctdb/config/debug_locks.sh index 5d4400443d9..8c9b46657fa 100755 --- a/ctdb/config/debug_locks.sh +++ b/ctdb/config/debug_locks.sh @@ -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]