diff options
author | John Ericson <git@JohnEricson.me> | 2019-11-04 19:52:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-04 19:52:33 -0500 |
commit | acd2d19484e5c79306110463fe621436fb228d4e (patch) | |
tree | 2ab5f59970230c26f97821aecb228495926f26a3 /pkgs | |
parent | 0a9e548b2f8c2a65ba5ee7b9b7695293c633af3b (diff) | |
parent | c5cf0099967e0f5011b9188d56de22c376465b88 (diff) |
Merge pull request #72347 from NixOS/bash-no-undef-vars
treewide: `set -u` everywhere
Diffstat (limited to 'pkgs')
64 files changed, 88 insertions, 134 deletions
diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index e02e77de45e4..9f5395b635e0 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -111,17 +111,13 @@ stdenv.mkDerivation { installPhase = '' - set -u - mkdir -p $out/bin $out/nix-support wrap() { local dst="$1" local wrapper="$2" export prog="$3" - set +u substituteAll "$wrapper" "$out/bin/$dst" - set -u chmod +x "$out/bin/$dst" } '' @@ -163,8 +159,6 @@ stdenv.mkDerivation { [[ -e "$underlying" ]] || continue wrap ${targetPrefix}$variant ${./ld-wrapper.sh} $underlying done - - set +u ''; emulation = let @@ -307,7 +301,6 @@ stdenv.mkDerivation { '' + '' - set +u substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash diff --git a/pkgs/build-support/build-dotnet-package/default.nix b/pkgs/build-support/build-dotnet-package/default.nix index f36c69e43392..dae9ed888c75 100644 --- a/pkgs/build-support/build-dotnet-package/default.nix +++ b/pkgs/build-support/build-dotnet-package/default.nix @@ -29,9 +29,9 @@ attrsOrig @ configurePhase = '' runHook preConfigure - [ -z "$dontPlacateNuget" ] && placate-nuget.sh - [ -z "$dontPlacatePaket" ] && placate-paket.sh - [ -z "$dontPatchFSharpTargets" ] && patch-fsharp-targets.sh + [ -z "''${dontPlacateNuget-}" ] && placate-nuget.sh + [ -z "''${dontPlacatePaket-}" ] && placate-paket.sh + [ -z "''${dontPatchFSharpTargets-}" ] && patch-fsharp-targets.sh runHook postConfigure ''; @@ -69,7 +69,7 @@ attrsOrig @ cp -rv ${arrayToShell outputFiles} "''${outputFilesArray[@]}" "$target" - if [ -z "$dontRemoveDuplicatedDlls" ] + if [ -z "''${dontRemoveDuplicatedDlls-}" ] then pushd "$out" remove-duplicated-dlls.sh diff --git a/pkgs/build-support/setup-hooks/audit-tmpdir.sh b/pkgs/build-support/setup-hooks/audit-tmpdir.sh index 5264ce398511..c9dd32d1dd22 100644 --- a/pkgs/build-support/setup-hooks/audit-tmpdir.sh +++ b/pkgs/build-support/setup-hooks/audit-tmpdir.sh @@ -7,7 +7,7 @@ # the moment that would produce too many spurious errors (e.g. debug # info or assertion messages that refer to $TMPDIR). -fixupOutputHooks+=('if [ -z "$noAuditTmpdir" -a -e "$prefix" ]; then auditTmpdir "$prefix"; fi') +fixupOutputHooks+=('if [[ -z "${noAuditTmpdir-}" && -e "$prefix" ]]; then auditTmpdir "$prefix"; fi') auditTmpdir() { local dir="$1" diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 6af8eb1aed99..52c50091d08c 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -228,7 +228,7 @@ autoPatchelf() { # behaviour as fixupOutputHooks because the setup hook for patchelf is run in # fixupOutput and the postFixup hook runs later. postFixupHooks+=(' - if [ -z "$dontAutoPatchelf" ]; then + if [ -z "${dontAutoPatchelf-}" ]; then autoPatchelf -- $(for output in $outputs; do [ -e "${!output}" ] || continue echo "${!output}" diff --git a/pkgs/build-support/setup-hooks/compress-man-pages.sh b/pkgs/build-support/setup-hooks/compress-man-pages.sh index d10a898d6e46..82e48cd8aa77 100644 --- a/pkgs/build-support/setup-hooks/compress-man-pages.sh +++ b/pkgs/build-support/setup-hooks/compress-man-pages.sh @@ -1,4 +1,4 @@ -fixupOutputHooks+=('if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi') +fixupOutputHooks+=('if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi') compressManPages() { local dir="$1" diff --git a/pkgs/build-support/setup-hooks/find-xml-catalogs.sh b/pkgs/build-support/setup-hooks/find-xml-catalogs.sh index 85364a61f612..f446a6f27fd9 100644 --- a/pkgs/build-support/setup-hooks/find-xml-catalogs.sh +++ b/pkgs/build-support/setup-hooks/find-xml-catalogs.sh @@ -11,12 +11,12 @@ addXMLCatalogs () { done } -if [ -z "$libxmlHookDone" ]; then +if [ -z "${libxmlHookDone-}" ]; then libxmlHookDone=1 # Set up XML_CATALOG_FILES. An empty initial value prevents # xmllint and xsltproc from looking in /etc/xml/catalog. - export XML_CATALOG_FILES + export XML_CATALOG_FILES='' if [ -z "$XML_CATALOG_FILES" ]; then XML_CATALOG_FILES=" "; fi addEnvHooks "$hostOffset" addXMLCatalogs fi diff --git a/pkgs/build-support/setup-hooks/move-lib64.sh b/pkgs/build-support/setup-hooks/move-lib64.sh index 7724be369c9c..9517af797323 100644 --- a/pkgs/build-support/setup-hooks/move-lib64.sh +++ b/pkgs/build-support/setup-hooks/move-lib64.sh @@ -8,7 +8,7 @@ fixupOutputHooks+=(_moveLib64) _moveLib64() { - if [ "$dontMoveLib64" = 1 ]; then return; fi + if [ "${dontMoveLib64-}" = 1 ]; then return; fi if [ ! -e "$prefix/lib64" -o -L "$prefix/lib64" ]; then return; fi echo "moving $prefix/lib64/* to $prefix/lib" mkdir -p $prefix/lib diff --git a/pkgs/build-support/setup-hooks/move-sbin.sh b/pkgs/build-support/setup-hooks/move-sbin.sh index cc51c27cafdf..1c0c4dc9f2d9 100644 --- a/pkgs/build-support/setup-hooks/move-sbin.sh +++ b/pkgs/build-support/setup-hooks/move-sbin.sh @@ -5,7 +5,7 @@ fixupOutputHooks+=(_moveSbin) _moveSbin() { - if [ "$dontMoveSbin" = 1 ]; then return; fi + if [ "${dontMoveSbin-}" = 1 ]; then return; fi if [ ! -e "$prefix/sbin" -o -L "$prefix/sbin" ]; then return; fi echo "moving $prefix/sbin/* to $prefix/bin" mkdir -p $prefix/bin diff --git a/pkgs/build-support/setup-hooks/multiple-outputs.sh b/pkgs/build-support/setup-hooks/multiple-outputs.sh index d43b18776742..2e95495c96fd 100644 --- a/pkgs/build-support/setup-hooks/multiple-outputs.sh +++ b/pkgs/build-support/setup-hooks/multiple-outputs.sh @@ -9,8 +9,8 @@ _assignFirst() { local varName="$1" local REMOVE=REMOVE # slightly hacky - we allow REMOVE (i.e. not a variable name) shift - while [ $# -ge 1 ]; do - if [ -n "${!1}" ]; then eval "${varName}"="$1"; return; fi + while (( $# )); do + if [ -n "${!1-}" ]; then eval "${varName}"="$1"; return; fi shift done echo "Error: _assignFirst found no valid variant!" @@ -19,7 +19,7 @@ _assignFirst() { # Same as _assignFirst, but only if "$1" = "" _overrideFirst() { - if [ -z "${!1}" ]; then + if [ -z "${!1-}" ]; then _assignFirst "$@" fi } diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index 3e900d0704cf..29fed7ad7940 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -105,7 +105,7 @@ patchShebangs() { } patchShebangsAuto () { - if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then + if [ -z "${dontPatchShebangs-}" -a -e "$prefix" ]; then # Dev output will end up being run on the build platform. An # example case of this is sdl2-config. Otherwise, we can just diff --git a/pkgs/build-support/setup-hooks/prune-libtool-files.sh b/pkgs/build-support/setup-hooks/prune-libtool-files.sh index 5d7432e8f09a..0ec56549645c 100644 --- a/pkgs/build-support/setup-hooks/prune-libtool-files.sh +++ b/pkgs/build-support/setup-hooks/prune-libtool-files.sh @@ -8,7 +8,7 @@ fixupOutputHooks+=(_pruneLibtoolFiles) _pruneLibtoolFiles() { - if [ "$dontPruneLibtoolFiles" ] || [ ! -e "$prefix" ]; then + if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then return fi diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh index fc4c7bfbaf95..f5fa9378fd7e 100644 --- a/pkgs/build-support/setup-hooks/strip.sh +++ b/pkgs/build-support/setup-hooks/strip.sh @@ -10,7 +10,7 @@ _doStrip() { local -ra stripCmds=(STRIP TARGET_STRIP) # Optimization - if [[ "$STRIP" == "$TARGET_STRIP" ]]; then + if [[ "${STRIP-}" == "${TARGET_STRIP-}" ]]; then dontStripTarget+=1 fi @@ -20,7 +20,7 @@ _doStrip() { local -n stripCmd="${stripCmds[$i]}" # `dontStrip` disables them all - if [[ "$dontStrip" || "$flag" ]] || ! type -f "$stripCmd" 2>/dev/null + if [[ "${dontStrip-}" || "${flag-}" ]] || ! type -f "${stripCmd-}" 2>/dev/null then continue; fi stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin} diff --git a/pkgs/build-support/setup-hooks/update-autotools-gnu-config-scripts.sh b/pkgs/build-support/setup-hooks/update-autotools-gnu-config-scripts.sh index 66f4e91c7bb6..ebd3afa05d94 100644 --- a/pkgs/build-support/setup-hooks/update-autotools-gnu-config-scripts.sh +++ b/pkgs/build-support/setup-hooks/update-autotools-gnu-config-scripts.sh @@ -1,7 +1,7 @@ preConfigurePhases+=" updateAutotoolsGnuConfigScriptsPhase" updateAutotoolsGnuConfigScriptsPhase() { - if [ -n "$dontUpdateAutotoolsGnuConfigScripts" ]; then return; fi + if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then return; fi for script in config.sub config.guess; do for f in $(find . -type f -name "$script"); do diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh index 717740f1f20f..a05d4f689db9 100644 --- a/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh @@ -15,7 +15,7 @@ wrapGApp() { wrapProgram "$program" "${gappsWrapperArgs[@]}" "$@" } -# Note: $gappsWrapperArgs still gets defined even if $dontWrapGApps is set. +# Note: $gappsWrapperArgs still gets defined even if ${dontWrapGApps-} is set. wrapGAppsHook() { # guard against running multiple times (e.g. due to propagation) [ -z "$wrapGAppsHookHasRun" ] || return 0 diff --git a/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix b/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix index 03857627952d..3b9cb752b9b8 100644 --- a/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix +++ b/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix @@ -37,7 +37,7 @@ let cpuName = stdenv.hostPlatform.parsed.cpu.name; # Set JAVA_HOME automatically. cat <<EOF >> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix b/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix index 509050209fb2..fe38f2b21633 100644 --- a/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix +++ b/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix @@ -54,7 +54,7 @@ let result = stdenv.mkDerivation rec { # Set JAVA_HOME automatically. cat <<EOF >> "$out/nix-support/setup-hook" - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/graalvm/default.nix b/pkgs/development/compilers/graalvm/default.nix index 61e3b6c16aee..5108ce185449 100644 --- a/pkgs/development/compilers/graalvm/default.nix +++ b/pkgs/development/compilers/graalvm/default.nix @@ -270,7 +270,7 @@ in rec { # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat <<EOF > $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; postFixup = openjdk.postFixup or null; diff --git a/pkgs/development/compilers/graalvm/enterprise-edition.nix b/pkgs/development/compilers/graalvm/enterprise-edition.nix index 84cb38aa8d11..e180455cb7cd 100644 --- a/pkgs/development/compilers/graalvm/enterprise-edition.nix +++ b/pkgs/development/compilers/graalvm/enterprise-edition.nix @@ -72,7 +72,7 @@ let # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat <<EOF > $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/11.nix b/pkgs/development/compilers/openjdk/11.nix index 57911f2d58e6..e365b9b28b35 100644 --- a/pkgs/development/compilers/openjdk/11.nix +++ b/pkgs/development/compilers/openjdk/11.nix @@ -106,7 +106,7 @@ let # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat <<EOF > $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/8.nix b/pkgs/development/compilers/openjdk/8.nix index 1a5848cd1a68..ff3d03321e21 100644 --- a/pkgs/development/compilers/openjdk/8.nix +++ b/pkgs/development/compilers/openjdk/8.nix @@ -231,7 +231,7 @@ let # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat <<EOF > $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/darwin/11.nix b/pkgs/development/compilers/openjdk/darwin/11.nix index 4c808302b4fa..0b659b95aa8b 100644 --- a/pkgs/development/compilers/openjdk/darwin/11.nix +++ b/pkgs/development/compilers/openjdk/darwin/11.nix @@ -44,7 +44,7 @@ let # Set JAVA_HOME automatically. cat <<EOF >> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/darwin/8.nix b/pkgs/development/compilers/openjdk/darwin/8.nix index d2fef9bb4812..bc7a33932b27 100644 --- a/pkgs/development/compilers/openjdk/darwin/8.nix +++ b/pkgs/development/compilers/openjdk/darwin/8.nix @@ -44,7 +44,7 @@ let # Set JAVA_HOME automatically. cat <<EOF >> $out/nix-support/setup-hook - if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ''; diff --git a/pkgs/development/compilers/openjdk/darwin/default.nix b/pkgs/development/compilers/openjdk/darwin/default.nix index 58e4ba990149..c954a8e2cf85 100644 --- a/pkgs/development/compilers/openjdk/darwin/default.nix +++ b/pkgs/developm |