aboutsummaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-11-11 21:27:37 +0100
committerGitHub <[email protected]>2021-11-11 13:27:37 -0700
commit420b44488ff91dc0f67c24faae5d580122b08cfb (patch)
treeb8278d4e5975d3c219598691ade23bd1b46e4ca4 /etc
parent49d42425d6dc9b55c8e83aa1b920fd0e08f7a142 (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 'etc')
-rwxr-xr-xetc/init.d/zfs-import.in3
-rw-r--r--etc/zfs/zfs-functions.in14
2 files changed, 7 insertions, 10 deletions
diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in
index e4bc7b833..130174f74 100755
--- a/etc/init.d/zfs-import.in
+++ b/etc/init.d/zfs-import.in
@@ -57,8 +57,7 @@ find_pools()
local pools
pools=$("$@" 2> /dev/null | \
- grep -E "pool:|^[a-zA-Z0-9]" | \
- sed 's@.*: @@' | \
+ sed -Ee '/pool:|^[a-zA-Z0-9]/!d' -e 's@.*: @@' | \
sort | \
tr '\n' ';')
diff --git a/etc/zfs/zfs-functions.in b/etc/zfs/zfs-functions.in
index 2fb065afd..a27d4c6cb 100644
--- a/etc/zfs/zfs-functions.in
+++ b/etc/zfs/zfs-functions.in
@@ -345,7 +345,7 @@ read_mtab()
# Unset all MTAB_* variables
# shellcheck disable=SC2046
- unset $(env | grep ^MTAB_ | sed 's,=.*,,')
+ unset $(env | sed -e '/^MTAB_/!d' -e 's,=.*,,')
while read -r fs mntpnt fstype opts rest; do
if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then
@@ -360,9 +360,8 @@ read_mtab()
fs=$(/bin/echo "$fs" | sed 's,\\0,\\00,')
# Remove 'unwanted' characters.
- mntpnt=$(printf '%b\n' "$mntpnt" | sed -e 's,/,,g' \
- -e 's,-,,g' -e 's,\.,,g' -e 's, ,,g')
- fs=$(printf '%b\n' "$fs")
+ mntpnt=$(printf '%b' "$mntpnt" | tr -d '/. -')
+ fs=$(printf '%b' "$fs")
# Set the variable.
eval export "MTAB_$mntpnt=\"$fs\""
@@ -374,8 +373,7 @@ in_mtab()
{
local mntpnt="$1"
# Remove 'unwanted' characters.
- mntpnt=$(printf '%b\n' "$mntpnt" | sed -e 's,/,,g' \
- -e 's,-,,g' -e 's,\.,,g' -e 's, ,,g')
+ mntpnt=$(printf '%b' "$mntpnt" | tr -d '/. -')
local var
var="$(eval echo "MTAB_$mntpnt")"
@@ -391,7 +389,7 @@ read_fstab()
# Unset all FSTAB_* variables
# shellcheck disable=SC2046
- unset $(env | grep ^FSTAB_ | sed 's,=.*,,')
+ unset $(env | sed -e '/^FSTAB_/!d' -e 's,=.*,,')
i=0
while read -r fs mntpnt fstype opts; do
@@ -401,7 +399,7 @@ read_fstab()
if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then
eval export "FSTAB_dev_$i=$fs"
- fs=$(printf '%b\n' "$fs" | sed 's,/,_,g')
+ fs=$(printf '%b' "$fs" | tr '/' '_')
eval export "FSTAB_$i=$mntpnt"
i=$((i + 1))