main - tests: cleanup some shellcheck warns
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=773bc013778df631f9ee14e7a79d5f02211b1e67 Commit: 773bc013778df631f9ee14e7a79d5f02211b1e67 Parent: cc2293f18ed14f4b306c7e5b92e508a6981b4826 Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Feb 9 16:04:54 2023 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Fri Feb 10 17:50:27 2023 +0100
tests: cleanup some shellcheck warns
Reduce shellcheck warnings about missing {} for possible array dereference.
Make sure we are not loosing error code when assigning local vars and explicitely ignore 'errors' from standalone lines when needed.
Add some missing quotes.
Use $() instead of ancient ``
Avoid writing some temporary data into /tmp - test need to store files within its own 'testdir' - so it can be properly discarded.
--- scripts/lvm_import_vdo.sh | 4 ++-- test/lib/aux.sh | 48 ++++++++++++++++++++++++--------------------- test/lib/get.sh | 6 +++--- test/lib/lvm_vdo_wrapper.sh | 4 +++- 4 files changed, 34 insertions(+), 28 deletions(-)
scripts/lvm_import_vdo.sh +2 -2
@@ -255,11 +255,11 @@ convert2lvm_() { # Find largest matching VG name to our 'default' vgname LASTVGNAME=$(LC_ALL=C "$LVM" vgs -oname -O-name --noheadings -S name=~${VGNAME} | grep -E "${VGNAME}[0-9]? ?" | head -1 || true) if test -n "$LASTVGNAME" ; then - LASTVGNAME=${LASTVGNAME#*${VGNAME}} + LASTVGNAME=${LASTVGNAME#*"${VGNAME}"} # If the number is becoming too high, try some random number test "$LASTVGNAME" -gt 99999999 2>/dev/null && LASTVGNAME=$RANDOM # Generate new unused VG name - VGNAME="${VGNAME}$(( ${LASTVGNAME} + 1 ))" + VGNAME="${VGNAME}$(( LASTVGNAME + 1 ))" verbose "Selected unused volume group name $VGNAME." fi fi
test/lib/aux.sh +26 -22
144 lines not on this page · raw message
test/lib/get.sh +3 -3
@@ -23,8 +23,8 @@ test -z "$BASH" || set -e -o pipefail # trims only leading prefix and suffix trim_() { rm -f debug.log # drop log, command was ok - local var=${1%${1##*[! ]}} # remove trailing space characters - echo "${var#${var%%[! ]*}}" # remove leading space characters + local var=${1%"${1##*[! ]}"} # remove trailing space characters + echo "${var#"${var%%[! ]*}"}" # remove leading space characters } pv_field() {
@@ -68,7 +68,7 @@ lv_devices() { } lv_field_lv_() { - lv_field "$1" "$2" -a --unbuffered | tr -d [] + lv_field "$1" "$2" -a --unbuffered | tr -d '[]' } lv_tree_devices_() {
test/lib/lvm_vdo_wrapper.sh +3 -1
@@ -87,8 +87,10 @@ local vdo_maxDiscardSize=${vdo_maxDiscardSize-4K} local vdo_name=${vdo_name-VDONAME} local vdo_physicalThreads=${vdo_physicalThreads-1} local vdo_slabSize=${vdo_slabSize-2G} -local vdo_uuid="VDO-$(uuidgen || echo \"f7a3ecdc-40a0-4e43-814c-4a7039a75de4\")" local vdo_writePolicy=${vdo_writePolicy-auto} +local vdo_uuid + +vdo_uuid="VDO-$(uuidgen || echo \"f7a3ecdc-40a0-4e43-814c-4a7039a75de4\")" while [ "$#" -ne 0 ] do