Remove basename(1). Clean up/shorten some coreutils pipelines

Basenames that remain, in cmd/zed/zed.d/statechange-led.sh:
	dev=$(basename "$(echo "$therest" | awk '{print $(NF-1)}')")
	vdev=$(basename "$ZEVENT_VDEV_PATH")
I don't wanna interfere with #11988

scripts/zfs-tests.sh:
	SINGLETESTFILE=$(basename "$SINGLETEST")
tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib:
	ACTUAL=$(basename $dataset)
	ACTUAL=$(basename $dataset)
tests/zfs-tests/tests/functional/cli_user/zpool_iostat/
	zpool_iostat_-c_homedir.ksh:
	typeset USER_SCRIPT=$(basename "$USER_SCRIPT_FULL")
tests/zfs-tests/tests/functional/cli_user/zpool_iostat/
	zpool_iostat_-c_searchpath.ksh:
	typeset CMD_1=$(basename "$SCRIPT_1")
	typeset CMD_2=$(basename "$SCRIPT_2")
tests/zfs-tests/tests/functional/cli_user/zpool_status/
	zpool_status_-c_homedir.ksh:
	typeset USER_SCRIPT=$(basename "$USER_SCRIPT_FULL")
tests/zfs-tests/tests/functional/cli_user/zpool_status/
	zpool_status_-c_searchpath.ksh
	typeset CMD_1=$(basename "$SCRIPT_1")
	typeset CMD_2=$(basename "$SCRIPT_2")
tests/zfs-tests/tests/functional/migration/migration.cfg:
	export BNAME=`basename $TESTFILE`
tests/zfs-tests/tests/perf/perf.shlib:
	typeset logbase="$(get_perf_output_dir)/$(basename \
tests/zfs-tests/tests/perf/perf.shlib:
	typeset logbase="$(get_perf_output_dir)/$(basename \

These are potentially Of Directories, where basename is actually
useful

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12652
This commit is contained in:
наб
2021-11-11 21:27:37 +01:00
committed by GitHub
parent 49d42425d6
commit 420b44488f
27 changed files with 67 additions and 75 deletions
+4 -6
View File
@@ -16,14 +16,12 @@ if [ -L "$dev" ] ; then
dev=$(readlink "$dev")
fi
dev=$(basename "$dev")
dev="${dev##*/}"
val=""
if [ -d "/sys/class/block/$dev/slaves" ] ; then
# ls -C: output in columns, no newlines
val=$(ls -C "/sys/class/block/$dev/slaves")
# ls -C will print two spaces between files; change to one space.
val=$(echo "$val" | sed -r 's/[[:blank:]]+/ /g')
# ls -C: output in columns, no newlines, two spaces (change to one)
# shellcheck disable=SC2012
val=$(ls -C "/sys/class/block/$dev/slaves" | tr -s '[:space:]' ' ')
fi
echo "dm-deps=$val"
+3 -3
View File
@@ -9,7 +9,7 @@ iostat: Show iostat values since boot (summary page).
iostat-1s: Do a single 1-second iostat sample and show values.
iostat-10s: Do a single 10-second iostat sample and show values."
script=$(basename "$0")
script="${0##*/}"
if [ "$1" = "-h" ] ; then
echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
exit
@@ -42,7 +42,7 @@ else
${brief:+"-y"} \
${interval:+"$interval"} \
${interval:+"1"} \
"$VDEV_UPATH" | awk NF | tail -n 2)
"$VDEV_UPATH" | grep -v '^$' | tail -n 2)
fi
@@ -61,7 +61,7 @@ fi
cols=$(echo "$out" | head -n 1)
# Get the values and tab separate them to make them cut-able.
vals=$(echo "$out" | tail -n 1 | sed -r 's/[[:blank:]]+/\t/g')
vals=$(echo "$out" | tail -n 1 | tr -s '[:space:]' '\t')
i=0
for col in $cols ; do
+1 -1
View File
@@ -48,7 +48,7 @@ size: Show the disk capacity.
vendor: Show the disk vendor.
lsblk: Show the disk size, vendor, and model number."
script=$(basename "$0")
script="${0##*/}"
if [ "$1" = "-h" ] ; then
echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
+6 -9
View File
@@ -9,15 +9,12 @@ if [ "$1" = "-h" ] ; then
fi
if [ -b "$VDEV_UPATH" ]; then
device=$(basename "$VDEV_UPATH")
val=$(cat "/sys/block/$device/queue/rotational" 2>/dev/null)
if [ "$val" = "0" ]; then
MEDIA="ssd"
fi
if [ "$val" = "1" ]; then
MEDIA="hdd"
fi
device="${VDEV_UPATH##*/}"
read -r val 2>/dev/null < "/sys/block/$device/queue/rotational"
case "$val" in
0) MEDIA="ssd" ;;
1) MEDIA="hdd" ;;
esac
vpd_pg83="/sys/block/$device/device/vpd_pg83"
if [ -f "$vpd_pg83" ]; then
+1 -1
View File
@@ -11,7 +11,7 @@ fault_led: Show value of the disk enclosure slot fault LED.
locate_led: Show value of the disk enclosure slot locate LED.
ses: Show disk's enc, enc device, slot, and fault/locate LED values."
script=$(basename "$0")
script="${0##*/}"
if [ "$1" = "-h" ] ; then
echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
exit