- Add new SC2312 global exclude.
```
Consider invoking this command separately to avoid masking its return
value (or use '|| true' to ignore). [SC2312]
```
- Correct errors detected by new ShellCheck version.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #14148
dir="${dir%/Makefile.am}"
grep -q '%[CD]%' "$dir/Makefile.am" || continue
- reldir="${dir#$root}"
+ reldir="${dir#"$root"}"
reldir="${reldir#/}"
canon_reldir="$(printf '%s' "$reldir" | tr -C 'a-zA-Z0-9@_' '_')"
# ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090]
# Not following: a was not specified as input (see shellcheck -x). [SC1091]
# Prefer putting braces around variable references even when not strictly required. [SC2250]
+# Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore). [SC2312]
# In POSIX sh, 'local' is undefined. [SC2039] # older ShellCheck versions
# In POSIX sh, 'local' is undefined. [SC3043] # newer ShellCheck versions
_STGT = $(subst ^,/,$(subst shellcheck-here-,,$@))
shellcheck-here-%:
if HAVE_SHELLCHECK
- shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") "$$([ -e "$(_STGT)" ] || echo "$(srcdir)/")$(_STGT)"
+ shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC2312,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") "$$([ -e "$(_STGT)" ] || echo "$(srcdir)/")$(_STGT)"
else
@echo "skipping shellcheck of" $(_STGT) "because shellcheck is not installed"
endif
__zfs_match_snapshot()
{
local base_dataset="${cur%@*}"
- if [ "$base_dataset" != "$cur" ]
+ if [[ "$base_dataset" != "$cur" ]]
then
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 "$base_dataset"
else
- if [ "$cur" != "" ] && __zfs_list_datasets "$cur" &> /dev/null
+ if [[ "$cur" != "" ]] && __zfs_list_datasets "$cur" &> /dev/null
then
$__ZFS_CMD list -H -o name -s name -t filesystem,volume -r "$cur" | tail -n +2
# We output the base dataset name even though we might be
__zfs_match_snapshot_or_bookmark()
{
local base_dataset="${cur%[#@]*}"
- if [ "$base_dataset" != "$cur" ]
+ if [[ "$base_dataset" != "$cur" ]]
then
if [[ $cur == *@* ]]
then
fi
else
$__ZFS_CMD list -H -o name -s name -t filesystem,volume
- if [ -e "$cur" ] && $__ZFS_CMD list -H -o name -s name -t filesystem,volume "$cur" &> /dev/null
+ if [[ -e "$cur" ]] && $__ZFS_CMD list -H -o name -s name -t filesystem,volume "$cur" &> /dev/null
then
echo "$cur@"
echo "$cur#"
{
local existing_opts
existing_opts="$(expr "$cur" : '\(.*\)[%,]')"
- if [ -e "$existing_opts" ]
+ if [[ -e "$existing_opts" ]]
then
local base_dataset="${cur%@*}"
- if [ "$base_dataset" != "$cur" ]
+ if [[ "$base_dataset" != "$cur" ]]
then
local cur="${cur##*,}"
if [[ $cur =~ ^%|%.*% ]]
mapfile -t COMPREPLY < <(compgen -W "$options" -- "${cur##*,}")
existing_opts=$(expr "$cur" : '\(.*,\)')
- if [ -n "$existing_opts" ]
+ if [[ -n "$existing_opts" ]]
then
COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" )
fi
get_devtype() {
local typ
typ=$(udevadm info --query=property --name="$1" | sed -n 's|^ID_FS_TYPE=||p')
- if [ -z "$typ" ] ; then
+ if [[ -z "$typ" ]] ; then
typ=$(blkid -c /dev/null "$1" -o value -s TYPE)
fi
echo "$typ"
else
awk -F '\t' '/\t\/dev/ { print $2 }' "$poolconfigtemp" | \
while read -r pooldev ; do
- if [ -e "$pooldev" ] ; then
+ if [[ -e "$pooldev" ]] ; then
resolved="$(readlink -f "$pooldev")"
dinfo "zfsexpandknowledge: pool $1 has device $pooldev (which resolves to $resolved)"
echo "$resolved"
local fstype
local _
numfields="$(awk '{print NF; exit}' /proc/self/mountinfo)"
- if [ "$numfields" = "10" ] ; then
+ if [[ "$numfields" = "10" ]] ; then
fields="_ _ _ _ mp _ _ fstype dev _"
else
fields="_ _ _ _ mp _ _ _ fstype dev _"
fi
# shellcheck disable=SC2086
while read -r ${fields?} ; do
- [ "$fstype" = "zfs" ] || continue
- [ "$mp" = "$1" ] && get_pool_devices "${dev%%/*}"
+ [[ "$fstype" = "zfs" ]] || continue
+ [[ "$mp" = "$1" ]] && get_pool_devices "${dev%%/*}"
done < /proc/self/mountinfo
}
local _depdevtype
# shellcheck disable=SC2154
-if [ -n "$hostonly" ]; then
+if [[ -n "$hostonly" ]]; then
for mp in \
"/" \
mp=$(readlink -f "$mp")
mountpoint "$mp" >/dev/null 2>&1 || continue
blockdevs=$(find_zfs_block_devices "$mp")
- if [ -z "$blockdevs" ] ; then continue ; fi
+ if [[ -z "$blockdevs" ]] ; then continue ; fi
dinfo "zfsexpandknowledge: block devices backing ZFS dataset $mp: ${blockdevs//$'\n'/ }"
for dev in $blockdevs
do
fstype=$(get_devtype "$dev")
host_fs_types["$dev"]="$fstype"
majmin=$(get_maj_min "$dev")
- if [ -d "/sys/dev/block/$majmin/slaves" ] ; then
+ if [[ -d "/sys/dev/block/$majmin/slaves" ]] ; then
for _depdev in "/sys/dev/block/$majmin/slaves"/*; do
- [ -f "$_depdev/dev" ] || continue
+ [[ -f "$_depdev/dev" ]] || continue
_depdev="/dev/${_depdev##*/}"
_depdevname=$(udevadm info --query=property --name="$_depdev" | sed -n 's|^DEVNAME=||p')
_depdevtype=$(get_devtype "$_depdevname")
check() {
# We depend on udev-rules being loaded
- [ "${1}" = "-d" ] && return 0
+ [[ "${1}" = "-d" ]] && return 0
# Verify the zfs tool chain
for tool in "zgenhostid" "zpool" "zfs" "mount.zfs"; do
fi
inst_hook cmdline 95 "${moddir}/parse-zfs.sh"
- if [ -n "${systemdutildir}" ]; then
+ if [[ -n "${systemdutildir}" ]]; then
inst_script "${moddir}/zfs-generator.sh" "${systemdutildir}/system-generators/dracut-zfs-generator"
fi
inst_hook pre-mount 90 "${moddir}/zfs-load-key.sh"
# Synchronize initramfs and system hostid
if ! inst_simple -H @sysconfdir@/hostid; then
- if HOSTID="$(hostid 2>/dev/null)" && [ "${HOSTID}" != "00000000" ]; then
+ if HOSTID="$(hostid 2>/dev/null)" && [[ "${HOSTID}" != "00000000" ]]; then
zgenhostid -o "${initdir}@sysconfdir@/hostid" "${HOSTID}"
mark_hostonly @sysconfdir@/hostid
fi
# rpool/ROOT/debian/boot@snap2 => rpool/ROOT/debian_snap2/boot
# rpool/ROOT/debian/usr@snap2 => rpool/ROOT/debian_snap2/usr
# rpool/ROOT/debian/var@snap2 => rpool/ROOT/debian_snap2/var
- subfs="${s##$rootfs}"
- subfs="${subfs%%@$snapname}"
+ subfs="${s##"$rootfs"}"
+ subfs="${subfs%%@"$snapname"}"
destfs="${rootfs}_${snapname}" # base fs.
[ -n "$subfs" ] && destfs="${destfs}$subfs" # + sub fs.
export SCRIPT_DIR=
# General commands
-export ZDB=${ZDB:-$SBIN_DIR/zdb}
-export ZFS=${ZFS:-$SBIN_DIR/zfs}
-export ZPOOL=${ZPOOL:-$SBIN_DIR/zpool}
-export ZTEST=${ZTEST:-$SBIN_DIR/ztest}
-export ZFS_SH=${ZFS_SH:-$SCRIPT_DIR/zfs.sh}
+export ZDB="${ZDB:-$SBIN_DIR/zdb}"
+export ZFS="${ZFS:-$SBIN_DIR/zfs}"
+export ZPOOL="${ZPOOL:-$SBIN_DIR/zpool}"
+export ZTEST="${ZTEST:-$SBIN_DIR/ztest}"
+export ZFS_SH="${ZFS_SH:-$SCRIPT_DIR/zfs.sh}"
# Test Suite
-export RUNFILE_DIR=${RUNFILE_DIR:-$ZTS_DIR/runfiles}
-export TEST_RUNNER=${TEST_RUNNER:-$ZTS_DIR/test-runner/bin/test-runner.py}
-export ZTS_REPORT=${ZTS_REPORT:-$ZTS_DIR/test-runner/bin/zts-report.py}
-export STF_TOOLS=${STF_TOOLS:-$ZTS_DIR/test-runner}
-export STF_SUITE=${STF_SUITE:-$ZTS_DIR/zfs-tests}
+export RUNFILE_DIR="${RUNFILE_DIR:-$ZTS_DIR/runfiles}"
+export TEST_RUNNER="${TEST_RUNNER:-$ZTS_DIR/test-runner/bin/test-runner.py}"
+export ZTS_REPORT="${ZTS_REPORT:-$ZTS_DIR/test-runner/bin/zts-report.py}"
+export STF_TOOLS="${STF_TOOLS:-$ZTS_DIR/test-runner}"
+export STF_SUITE="${STF_SUITE:-$ZTS_DIR/zfs-tests}"
#!/usr/bin/env bash
-# shellcheck disable=SC2086
+# shellcheck disable=SC2086,SC2295
# kmodtool - Helper script for building kernel module RPMs
# Copyright (c) 2003-2012 Ville Skyttä <ville.skytta@iki.fi>,
print_rpmtemplate_per_kmodpkg ()
{
- if [ "${1}" = "--custom" ]; then
+ if [[ "${1}" = "--custom" ]]; then
shift
local customkernel=true
- elif [ "${1}" = "--redhat" ]; then
+ elif [[ "${1}" = "--redhat" ]]; then
# this is needed for akmods
shift
local redhatkernel=true
# Detect depmod install location
local depmod_path=/sbin/depmod
- if [ ! -f "${depmod_path}" ]; then
+ if [[ ! -f "${depmod_path}" ]]; then
depmod_path=/usr/sbin/depmod
fi
EOF
# second part
- if [ -z "${customkernel}" ]; then
+ if [[ -z "${customkernel}" ]]; then
cat <<EOF
Requires: kernel-uname-r = ${kernel_uname_r}
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
%{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}}
%post -n kmod-${kmodname}-${kernel_uname_r}
-if [ -f "/boot/System.map-${kernel_uname_r}" ]; then
+if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
${prefix}${depmod_path} -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || :
-elif [ -f "/lib/modules/${kernel_uname_r}/System.map" ]; then
+elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
${prefix}${depmod_path} -aeF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} > /dev/null || :
else
${prefix}${depmod_path} -ae ${kernel_uname_r} &> /dev/null || :
fi
%postun -n kmod-${kmodname}-${kernel_uname_r}
-if [ -f "/boot/System.map-${kernel_uname_r}" ]; then
+if [[ -f "/boot/System.map-${kernel_uname_r}" ]]; then
${prefix}${depmod_path} -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || :
-elif [ -f "/lib/modules/${kernel_uname_r}/System.map" ]; then
+elif [[ -f "/lib/modules/${kernel_uname_r}/System.map" ]]; then
${prefix}${depmod_path} -aF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} &> /dev/null || :
else
${prefix}${depmod_path} -a ${kernel_uname_r} &> /dev/null || :
print_rpmtemplate_kmoddevelpkg ()
{
- if [ "${1}" = "--custom" ]; then
+ if [[ "${1}" = "--custom" ]]; then
shift
local customkernel=true
- elif [ "${1}" = "--redhat" ]; then
+ elif [[ "${1}" = "--redhat" ]]; then
shift
local redhatkernel=true
fi
Provides: ${kmodname}-devel-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
EOF
- if [ -z "${customkernel}" ] && [ -z "${redhatkernel}" ]; then
+ if [[ -z "${customkernel}" ]] && [[ -z "${redhatkernel}" ]]; then
echo "Requires: kmod-${kmodname}-devel-${kernel_uname_r} >= %{?epoch:%{epoch}:}%{version}-%{release}"
fi
print_rpmtemplate_per_kmoddevelpkg ()
{
- if [ "${1}" = "--custom" ]; then
+ if [[ "${1}" = "--custom" ]]; then
shift
local customkernel=true
- elif [ "${1}" = "--redhat" ]; then
+ elif [[ "${1}" = "--redhat" ]]; then
# this is needed for akmods
shift
local redhatkernel=true
EOF
# second part
- if [ -z "${customkernel}" ]; then
+ if [[ -z "${customkernel}" ]]; then
cat <<EOF
Requires: kernel-devel-uname-r = ${kernel_uname_r}
BuildRequires: kernel-devel-uname-r = ${kernel_uname_r}
{
for kernel in ${1}
do
- if [ -e "${buildroot}/usr/src/kernels/${kernel}" ] ; then
+ if [[ -e "${buildroot}/usr/src/kernels/${kernel}" ]] ; then
# this looks like a Fedora/RH kernel -- print a normal template (which includes the proper BR) and be happy :)
kernel_versions="${kernel_versions}${kernel}___${buildroot}%{_usrsrc}/kernels/${kernel} "
print_rpmtemplate_per_kmodpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
# create development package
- if [ -n "${devel}" ]; then
+ if [[ -n "${devel}" ]]; then
# create devel package including common headers
print_rpmtemplate_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
# create devel package
print_rpmtemplate_per_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
fi
- elif [ -e "${prefix}/lib/modules/${kernel}/build/Makefile" ]; then
+ elif [[ -e "${prefix}/lib/modules/${kernel}/build/Makefile" ]]; then
# likely a user-build-kernel with available buildfiles
# fixme: we should check if uname from Makefile is the same as ${kernel}
print_rpmtemplate_per_kmodpkg --custom "${kernel}"
# create development package
- if [ -n "${devel}" ]; then
+ if [[ -n "${devel}" ]]; then
# create devel package including common headers
print_rpmtemplate_kmoddevelpkg --custom "${kernel}"
# create package
print_rpmtemplate_per_kmodpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
- if [ -n "${devel}" ]; then
+ if [[ -n "${devel}" ]]; then
# create devel package including common headers
print_rpmtemplate_kmoddevelpkg "${kernel}" "${kernel##${kernel_verrelarch}}"
echo " --buildroot <dir> -- Build root (place to look for build files)"
}
-while [ -n "${1}" ] ; do
+while [[ -n "${1}" ]] ; do
case "${1}" in
--filterfile)
shift
- if [ -z "${1}" ] ; then
+ if [[ -z "${1}" ]] ; then
error_out 2 "Please provide path to a filter-file together with --filterfile" >&2
- elif [ ! -e "${1}" ]; then
+ elif [[ ! -e "${1}" ]]; then
error_out 2 "Filterfile ${1} not found" >&2
fi
filterfile="${1}"
;;
--kmodname)
shift
- if [ -z "${1}" ] ; then
+ if [[ -z "${1}" ]] ; then
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
fi
# strip pending -kmod
;;
--prefix)
shift
- if [ -z "${1}" ] ; then
+ if [[ -z "${1}" ]] ; then
error_out 2 "Please provide a prefix with --prefix" >&2
fi
prefix="${1}"
;;
--repo)
shift
- if [ -z "${1}" ] ; then
+ if [[ -z "${1}" ]] ; then
error_out 2 "Please provide the name of the repo together with --repo" >&2
fi
repo=${1}
;;
--for-kernels)
shift
- if [ -z "${1}" ] ; then
+ if [[ -z "${1}" ]] ; then
error_out 2 "Please provide the name of the kmod together with --kmodname" >&2
fi
for_kernels="${1}"
esac
done
-if [ -e ./kmodtool-kernel-variants ]; then
+if [[ -e ./kmodtool-kernel-variants ]]; then
kernels_known_variants="$(cat ./kmodtool-kernel-variants)"
-elif [ -e /usr/share/kmodtool/kernel-variants ] ; then
+elif [[ -e /usr/share/kmodtool/kernel-variants ]] ; then
kernels_known_variants="$(cat /usr/share/kmodtool/kernel-variants)"
else
kernels_known_variants="@(smp?(-debug)|PAE?(-debug)|debug|kdump|xen|kirkwood|highbank|imx|omap|tegra)"
fi
# general sanity checks
-if [ -z "${target}" ]; then
+if [[ -z "${target}" ]]; then
error_out 2 "please pass target arch with --target"
-elif [ -z "${kmodname}" ]; then
+elif [[ -z "${kmodname}" ]]; then
error_out 2 "please pass kmodname with --kmodname"
-elif [ -z "${kernels_known_variants}" ] ; then
+elif [[ -z "${kernels_known_variants}" ]] ; then
error_out 2 "could not determine known variants"
fi
# go
-if [ -n "${for_kernels}" ]; then
+if [[ -n "${for_kernels}" ]]; then
# this is easy:
print_customrpmtemplate "${for_kernels}"
-elif [ "${build_kernels}" = "akmod" ]; then
+elif [[ "${build_kernels}" = "akmod" ]]; then
# do only a akmod package
print_akmodtemplate
print_akmodmeta
# seems we are on out own to decide for which kernels to build
# we need more sanity checks in this case
- if [ -z "${repo}" ]; then
+ if [[ -z "${repo}" ]]; then
error_out 2 "please provide repo name with --repo"
elif ! command -v "buildsys-build-${repo}-kerneldevpkgs" > /dev/null 2>&1; then
error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found"
cmdoptions="--target ${target}"
# filterfile to filter list of kernels?
- if [ -n "${filterfile}" ] ; then
+ if [[ -n "${filterfile}" ]] ; then
cmdoptions="${cmdoptions} --filterfile ${filterfile}"
fi
kernel_versions_to_build_for=$(buildsys-build-${repo}-kerneldevpkgs "--${build_kernels}" ${cmdoptions}) ||
error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: ${kernel_versions_to_build_for}"
- if [ "${build_kernels}" = "current" ] && [ -z "${noakmod}" ]; then
+ if [[ "${build_kernels}" = "current" ]] && [[ -z "${noakmod}" ]]; then
print_akmodtemplate
fi
BASE_DIR=$(dirname "$0")
SCRIPT_COMMON=common.sh
-if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
+if [[ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]]; then
. "${BASE_DIR}/${SCRIPT_COMMON}"
else
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
SRC_DIR="$TEST_DIR/src"
SRC_DIR_ZFS="$SRC_DIR/zfs"
-if [ "$COLOR" = "no" ]; then
+if [[ "$COLOR" = "no" ]]; then
COLOR_GREEN=""
COLOR_BROWN=""
COLOR_RED=""
ZFS_DIR="$SRC_DIR_ZFS/$ZFS_TAG"
ZFS_URL="$REPO/zfs/tarball/$ZFS_TAG"
- if [ "$TAG" = "installed" ]; then
+ if [[ "$TAG" = "installed" ]]; then
ZPOOL_CMD=$(command -v zpool)
ZFS_CMD=$(command -v zfs)
ZFS_SH="/usr/share/zfs/zfs.sh"
pool_set_vars "$1"
src_set_vars "$1"
- if [ "$POOL_TAG" != "installed" ]; then
+ if [[ "$POOL_TAG" != "installed" ]]; then
cd "$POOL_DIR_SRC" || fail "Failed 'cd $POOL_DIR_SRC'"
fi
# If the zfs-images directory doesn't exist fetch a copy from Github then
# cache it in the $TEST_DIR and update $IMAGES_DIR.
-if [ ! -d "$IMAGES_DIR" ]; then
+if [[ ! -d "$IMAGES_DIR" ]]; then
IMAGES_DIR="$TEST_DIR/zfs-images"
mkdir -p "$IMAGES_DIR"
curl -sL "$IMAGES_TAR" | \
# list of available images for the reserved keyword 'all'.
for TAG in $POOL_TAGS; do
- if [ "$TAG" = "all" ]; then
+ if [[ "$TAG" = "all" ]]; then
ALL_TAGS=$(echo "$IMAGES_DIR"/*.tar.bz2 | \
sed "s|$IMAGES_DIR/||g;s|.tar.bz2||g")
NEW_TAGS="$NEW_TAGS $ALL_TAGS"
done
POOL_TAGS="$NEW_TAGS"
-if [ "$VERBOSE" = "yes" ]; then
+if [[ "$VERBOSE" = "yes" ]]; then
echo "---------------------------- Options ----------------------------"
echo "VERBOSE=$VERBOSE"
echo "KEEP=$KEEP"
echo
fi
-if [ ! -d "$TEST_DIR" ]; then
+if [[ ! -d "$TEST_DIR" ]]; then
mkdir -p "$TEST_DIR"
fi
-if [ ! -d "$SRC_DIR" ]; then
+if [[ ! -d "$SRC_DIR" ]]; then
mkdir -p "$SRC_DIR"
fi
for TAG in $SRC_TAGS; do
src_set_vars "$TAG"
- if [ "$TAG" = "installed" ]; then
+ if [[ "$TAG" = "installed" ]]; then
ZFS_VERSION=$(modinfo zfs | awk '/version:/ { print $2; exit }')
- if [ -n "$ZFS_VERSION" ]; then
+ if [[ -n "$ZFS_VERSION" ]]; then
printf "%-16s" "$ZFS_VERSION"
else
fail "ZFS is not installed"
for TAG in $SRC_TAGS; do
src_set_vars "$TAG"
- if [ -d "$ZFS_DIR" ]; then
+ if [[ -d "$ZFS_DIR" ]]; then
skip_nonewline
- elif [ "$ZFS_TAG" = "installed" ]; then
+ elif [[ "$ZFS_TAG" = "installed" ]]; then
skip_nonewline
else
cd "$SRC_DIR" || fail "Failed 'cd $SRC_DIR'"
- if [ ! -d "$SRC_DIR_ZFS" ]; then
+ if [[ ! -d "$SRC_DIR_ZFS" ]]; then
mkdir -p "$SRC_DIR_ZFS"
fi
git archive --format=tar --prefix="$ZFS_TAG/ $ZFS_TAG" \
-o "$SRC_DIR_ZFS/$ZFS_TAG.tar" &>/dev/null || \
rm "$SRC_DIR_ZFS/$ZFS_TAG.tar"
- if [ -s "$SRC_DIR_ZFS/$ZFS_TAG.tar" ]; then
+ if [[ -s "$SRC_DIR_ZFS/$ZFS_TAG.tar" ]]; then
tar -xf "$SRC_DIR_ZFS/$ZFS_TAG.tar" -C "$SRC_DIR_ZFS"
rm "$SRC_DIR_ZFS/$ZFS_TAG.tar"
echo -n -e "${COLOR_GREEN}Local${COLOR_RESET}\t\t"
for TAG in $SRC_TAGS; do
src_set_vars "$TAG"
- if [ -f "$ZFS_DIR/module/zfs/zfs.ko" ]; then
+ if [[ -f "$ZFS_DIR/module/zfs/zfs.ko" ]]; then
skip_nonewline
- elif [ "$ZFS_TAG" = "installed" ]; then
+ elif [[ "$ZFS_TAG" = "installed" ]]; then
skip_nonewline
else
cd "$ZFS_DIR" || fail "Failed 'cd $ZFS_DIR'"
mkdir -p "$POOL_DIR_PRISTINE"
# Use the existing compressed image if available.
- if [ -f "$POOL_BZIP" ]; then
+ if [[ -f "$POOL_BZIP" ]]; then
tar -xjf "$POOL_BZIP" -C "$POOL_DIR_PRISTINE" \
--strip-components=1 || \
fail "Failed 'tar -xjf $POOL_BZIP"
# Use the installed version to create the pool.
- elif [ "$TAG" = "installed" ]; then
+ elif [[ "$TAG" = "installed" ]]; then
pool_create "$TAG"
# A source build is available to create the pool.
- elif [ -d "$POOL_DIR_SRC" ]; then
+ elif [[ -d "$POOL_DIR_SRC" ]]; then
pool_create "$TAG"
else
SKIP=1
# Verify 'zpool import' works for all listed source versions.
for SRC_TAG in $SRC_TAGS; do
- if [ "$SKIP" -eq 1 ]; then
+ if [[ "$SKIP" -eq 1 ]]; then
skip_nonewline
continue
fi
src_set_vars "$SRC_TAG"
- if [ "$SRC_TAG" != "installed" ]; then
+ if [[ "$SRC_TAG" != "installed" ]]; then
cd "$ZFS_DIR" || fail "Failed 'cd $ZFS_DIR'"
fi
$ZFS_SH zfs="spa_config_path=$POOL_DIR_COPY"
printf "\n"
done
-if [ "$KEEP" = "no" ]; then
+if [[ "$KEEP" = "no" ]]; then
rm -Rf "$TEST_DIR"
fi
BASE_DIR=${0%/*}
SCRIPT_COMMON=common.sh
-if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
+if [[ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]]; then
. "${BASE_DIR}/${SCRIPT_COMMON}"
else
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1