diff options
author | наб <[email protected]> | 2021-11-11 21:27:37 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-11-11 13:27:37 -0700 |
commit | 420b44488ff91dc0f67c24faae5d580122b08cfb (patch) | |
tree | b8278d4e5975d3c219598691ade23bd1b46e4ca4 /cmd/zpool | |
parent | 49d42425d6dc9b55c8e83aa1b920fd0e08f7a142 (diff) |
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 <[email protected]>
Reviewed-by: John Kennedy <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #12652
Diffstat (limited to 'cmd/zpool')
-rwxr-xr-x | cmd/zpool/zpool.d/dm-deps | 10 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/iostat | 6 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/lsblk | 2 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/media | 15 | ||||
-rwxr-xr-x | cmd/zpool/zpool.d/ses | 2 |
5 files changed, 15 insertions, 20 deletions
diff --git a/cmd/zpool/zpool.d/dm-deps b/cmd/zpool/zpool.d/dm-deps index ee39514e4..42af6a8d6 100755 --- a/cmd/zpool/zpool.d/dm-deps +++ b/cmd/zpool/zpool.d/dm-deps @@ -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" diff --git a/cmd/zpool/zpool.d/iostat b/cmd/zpool/zpool.d/iostat index 41a3acfae..19be475e9 100755 --- a/cmd/zpool/zpool.d/iostat +++ b/cmd/zpool/zpool.d/iostat @@ -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 diff --git a/cmd/zpool/zpool.d/lsblk b/cmd/zpool/zpool.d/lsblk index 1cdef4049..919783a1c 100755 --- a/cmd/zpool/zpool.d/lsblk +++ b/cmd/zpool/zpool.d/lsblk @@ -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- diff --git a/cmd/zpool/zpool.d/media b/cmd/zpool/zpool.d/media index 5683cdc3c..660f78b74 100755 --- a/cmd/zpool/zpool.d/media +++ b/cmd/zpool/zpool.d/media @@ -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 diff --git a/cmd/zpool/zpool.d/ses b/cmd/zpool/zpool.d/ses index b1836d676..b51fe3189 100755 --- a/cmd/zpool/zpool.d/ses +++ b/cmd/zpool/zpool.d/ses @@ -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 |