refactor: Use -n instead of ! -z

As recommended by ShellCheck.
This commit is contained in:
Victor Engmark 2023-01-10 17:01:52 +13:00
parent 388dfd8b5e
commit 148ac4c261

6
disko
View file

@ -91,7 +91,7 @@ if ! ([[ $mode = "create" ]] || [[ $mode = "mount" ]] || [[ $mode = "zap_create_
abort "mode must be either create, mount or zap_create_mount"
fi
if [[ ! -z "${flake+x}" ]]; then
if [[ -n "${flake+x}" ]]; then
if [[ $flake =~ ^(.*)\#([^\#\"]*)$ ]]; then
flake="${BASH_REMATCH[1]}"
flakeAttr="${BASH_REMATCH[2]}"
@ -104,7 +104,7 @@ if [[ ! -z "${flake+x}" ]]; then
nix_args+=("--arg" "flake" "$flake")
nix_args+=("--argstr" "flakeAttr" "$flakeAttr")
nix_args+=(--extra-experimental-features flakes)
elif [[ ! -z "${disko_config+x}" ]] && [[ -e "$disko_config" ]]; then
elif [[ -n "${disko_config+x}" ]] && [[ -e "$disko_config" ]]; then
nix_args+=("--arg" "diskoFile" "$disko_config")
else
abort "disko config must be an existing file or flake must be set"
@ -115,7 +115,7 @@ script=$(nix-build "${libexec_dir}"/cli.nix \
--argstr mode "$mode" \
"${nix_args[@]}"
)
if [[ ! -z "${dry_run+x}" ]]; then
if [[ -n "${dry_run+x}" ]]; then
echo "$script"
else
exec "$script"