Skip to content

Commit a888041

Browse files
committed
Address more Shellcheck findings
1 parent b237a06 commit a888041

5 files changed

Lines changed: 12 additions & 13 deletions

File tree

libexec/dataset_id.bash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export -f __dataset_id__cleanup
1616

1717
function __dataset_id__load_dataset_record {
1818
local pid exitstatus fifodir fifoname
19+
export dataset dataset_id
1920

2021
trap __dataset_id__cleanup EXIT INT HUP TERM
2122
fifodir="$(mktemp -d)"
@@ -24,7 +25,7 @@ function __dataset_id__load_dataset_record {
2425

2526
(__dataset_id__dataset_record "$@") > "${fifoname}" &
2627
pid="$!"
27-
IFS=$'\t' read -d $'\n' dataset dataset_id < "${fifoname}" \
28+
IFS=$'\t' read -r -d $'\n' dataset dataset_id < "${fifoname}" \
2829
|| true
2930

3031
wait "${pid}" || exitstatus="$?"
@@ -62,7 +63,7 @@ function __dataset_id__dataset_record {
6263
esac
6364
done
6465

65-
shift "$(($OPTIND-1))"
66+
shift "$((OPTIND-1))"
6667

6768
parent_dataset="$1"
6869

libexec/znaphodl.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function __znaphodl__load_target_dataset_record {
7878

7979
(__znaphodl__target_dataset_record) > "${fifoname}" &
8080
pid="$!"
81-
IFS=$'\t' read -d $'\n' target_dataset target_hostname \
81+
IFS=$'\t' read -r -d $'\n' target_dataset target_hostname \
8282
< "${fifoname}" \
8383
|| true
8484

@@ -180,7 +180,7 @@ function __znaphodl {
180180
esac
181181
done
182182

183-
shift "$(($OPTIND-1))"
183+
shift "$((OPTIND-1))"
184184

185185
source_dataset="${1?}"
186186
target_dataset_key="${2?}"

libexec/znaphodlz.bash

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ function __znaphodlz {
66
local home_poolname
77
local poolnames
88

9-
__zpoolz__load_poolnames
10-
if [[ "$?" -ne 0 ]]; then
9+
if ! __zpoolz__load_poolnames; then
1110
echo >&2 "Unable to identify pool names"
1211
return 1
1312
fi
1413

15-
if [[ ! "${poolnames[@]}" ]]; then
14+
if [[ ! "${poolnames}" ]]; then
1615
echo >&2 "No pools found"
1716
return 1
1817
fi

libexec/znaplizt.bash

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,18 @@ function __znaplizt {
6565
esac
6666
done
6767

68-
shift "$(($OPTIND-1))"
68+
shift "$((OPTIND-1))"
6969

70-
if [[ "$@" ]]; then
70+
if [[ "$#" -gt 0 ]]; then
7171
poolnames=("$@")
7272
else
73-
__zpoolz__load_poolnames
74-
if [[ "$?" -ne 0 ]]; then
73+
if ! __zpoolz__load_poolnames; then
7574
echo >&2 "Unable to identify pool names"
7675
return 1
7776
fi
7877
fi
7978

80-
if [[ ! "${poolnames[@]}" ]]; then
79+
if [[ "${#poolnames[@]}" -eq 0 ]]; then
8180
echo >&2 "No pools found"
8281
return 1
8382
fi

libexec/zpoolz.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function __zpoolz__load_poolnames {
1515

1616
(zpool list -H -o name) > "${fifoname}" &
1717
zpool_pid="$!"
18-
IFS=$'\n' read -a poolnames -d '' < "${fifoname}" || true
18+
IFS=$'\n' read -r -a poolnames -d '' < "${fifoname}" || true
1919

2020
wait "${zpool_pid}" || zpool_status="$?"
2121

0 commit comments

Comments
 (0)