From c27a74e37812b28b121216248470c4d5085f40cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 25 Jul 2022 22:38:41 +0200 Subject: [PATCH] nix: quote path uses to avoid issues with spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is most important on MacOS, but in general is a good idea. Resolves: https://github.com/status-im/status-mobile/issues/13715 Signed-off-by: Jakub SokoĊ‚owski --- nix/deps/gradle/add_package.sh | 4 ++-- nix/deps/gradle/generate.sh | 2 +- nix/deps/gradle/get_deps.sh | 2 +- nix/deps/gradle/get_projects.sh | 2 +- nix/scripts/build.sh | 2 +- nix/scripts/node_modules.sh | 16 ++++++++-------- nix/scripts/purge.sh | 2 +- nix/scripts/shell.sh | 2 +- nix/scripts/source.sh | 2 +- nix/shells.nix | 2 +- scripts/build-android.sh | 2 +- scripts/generate-keystore.sh | 2 +- scripts/sign-android.sh | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/nix/deps/gradle/add_package.sh b/nix/deps/gradle/add_package.sh index 6adf3ee0c6..9446215414 100755 --- a/nix/deps/gradle/add_package.sh +++ b/nix/deps/gradle/add_package.sh @@ -21,9 +21,9 @@ echo "${1}" | go-maven-resolver >> nix/deps/gradle/deps.urls sort -uo nix/deps/gradle/deps.urls nix/deps/gradle/deps.urls # Re-generate dependencies JSON. -${GIT_ROOT}/nix/deps/gradle/generate.sh gen_deps_json +"${GIT_ROOT}/nix/deps/gradle/generate.sh" gen_deps_json # Re-generate dependencies list. -${GIT_ROOT}/nix/deps/gradle/generate.sh gen_deps_list +"${GIT_ROOT}/nix/deps/gradle/generate.sh" gen_deps_list echo -e "${GRN}Successfully added:${RST} ${BLD}${1}${RST}" >&2 diff --git a/nix/deps/gradle/generate.sh b/nix/deps/gradle/generate.sh index 8dc85eb394..477662ff4f 100755 --- a/nix/deps/gradle/generate.sh +++ b/nix/deps/gradle/generate.sh @@ -68,7 +68,7 @@ function gen_deps_json() { echo "Regenerating Nix files..." # Gradle needs to be run in 'android' subfolder -cd $GIT_ROOT/android +cd "${GIT_ROOT}/android" # Stop gradle daemons to avoid locking ./gradlew --stop >/dev/null diff --git a/nix/deps/gradle/get_deps.sh b/nix/deps/gradle/get_deps.sh index 2962e26932..79570903b3 100755 --- a/nix/deps/gradle/get_deps.sh +++ b/nix/deps/gradle/get_deps.sh @@ -4,7 +4,7 @@ set -Eeu GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) # Gradle needs to be run in 'android' subfolder -cd $GIT_ROOT/android +cd "${GIT_ROOT}/android" AWK_SCRIPT="${GIT_ROOT}/nix/deps/gradle/gradle_parser.awk" diff --git a/nix/deps/gradle/get_projects.sh b/nix/deps/gradle/get_projects.sh index 71cd699d91..fd31d9fee6 100755 --- a/nix/deps/gradle/get_projects.sh +++ b/nix/deps/gradle/get_projects.sh @@ -4,7 +4,7 @@ set -Eeu GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) # Gradle needs to be run in 'android' subfolder -cd $GIT_ROOT/android +cd "${GIT_ROOT}/android" # Print all our sub-projects ./gradlew projects --no-daemon --console plain 2>&1 \ diff --git a/nix/scripts/build.sh b/nix/scripts/build.sh index 98e85892ff..2c9cea1c6d 100755 --- a/nix/scripts/build.sh +++ b/nix/scripts/build.sh @@ -55,7 +55,7 @@ nixOpts=( ) # Save derivation from being garbage collected -${GIT_ROOT}/nix/scripts/gcroots.sh "${TARGET}" "${@}" +"${GIT_ROOT}/nix/scripts/gcroots.sh" "${TARGET}" "${@}" # Run the actual build echo -e "${GRN}Running:${RST} ${BLD}nix-build "${nixOpts[@]}" ${@}${RST}" diff --git a/nix/scripts/node_modules.sh b/nix/scripts/node_modules.sh index 2835ee3a4f..eecd2fc900 100755 --- a/nix/scripts/node_modules.sh +++ b/nix/scripts/node_modules.sh @@ -34,7 +34,7 @@ copyNodeModules() { local dst="${2}" # WARNING: The ../ is there to avoid a Nix builtins.path bug: # https://github.com/NixOS/nix/issues/3593 - local tmp=$(mktemp -d -p "$(dirname ${dst})/../") + local tmp=$(mktemp -d -p "$(dirname "${dst}")/../") # We use a temporary directory to use mv as "atomic" change trap "removeDir ${tmp}" ERR INT HUP @@ -54,8 +54,8 @@ copyNodeModules() { findFilesNewerThan() { local sentinel="${1}" local dir="${2}" - find ${dir} -type f -writable \ - -newer ${sentinel} \ + find "${dir}" -type f -writable \ + -newer "${sentinel}" \ -not -ipath "*/*android/build/*" -prune \ -not -ipath "*/xcuserdata/*" -prune \ -not -ipath "*/unpacked_bin/clj-kondo" \ @@ -76,7 +76,7 @@ nodeModulesUnchanged() { fi # Sentinel file holds location of the node_modules source in Nix store - currentNixSrc="$(cat ${sentinelFile})" + currentNixSrc="$(cat "${sentinelFile}")" if [ "${currentNixSrc}" != "${src}" ]; then echo -e "${YLW}Yarn modules changed, copying new version over${RST}" >&2 @@ -89,7 +89,7 @@ nodeModulesUnchanged() { echo -e "${YLW}Changes detected in node_modules:${RST} ${#modifiedFiles[@]}" >&2 # Print files that have changes for file in ${modifiedFiles[@]}; do - echo "- $(realpath --relative-to=${dst} ${file})" >&2 + echo "- $(realpath --relative-to="${dst}" "${file}")" >&2 done return 1 fi @@ -103,14 +103,14 @@ replaceNodeModules() { local dst="$2" local sentinelFile="${dst}/.copied~" - if nodeModulesUnchanged ${src} ${dst}; then + if nodeModulesUnchanged "${src}" "${dst}"; then return fi # Replace node_modules if necessary echo "Copying node_modules from Nix store:" >&2 echo " - ${src}" >&2 - copyNodeModules ${src} ${dst} + copyNodeModules "${src}" "${dst}" echo -n "${src}" > "${sentinelFile}" } @@ -130,4 +130,4 @@ export -f replaceNodeModules nodeModulesUnchanged copyNodeModules findFilesNewer mkdir -p "${dst}" # Leverage file lock to create an exclusive lock. # Otherwise multiple calls to this script would clash. -flock "${dst}/" sh -c "time replaceNodeModules ${src} ${dst}" +flock "${dst}/" sh -c "time replaceNodeModules '${src}' '${dst}'" diff --git a/nix/scripts/purge.sh b/nix/scripts/purge.sh index ebf41c0481..ae24fa5a4d 100755 --- a/nix/scripts/purge.sh +++ b/nix/scripts/purge.sh @@ -75,7 +75,7 @@ nix_purge_user_profile() { ~/.nix-* \ ~/.cache/nix \ ~/.config/nixpkgs \ - ${GIT_ROOT}/.nix-gcroots + "${GIT_ROOT}/.nix-gcroots" } nix_purge_root() { diff --git a/nix/scripts/shell.sh b/nix/scripts/shell.sh index bee2b72ff8..4c61a21ef6 100755 --- a/nix/scripts/shell.sh +++ b/nix/scripts/shell.sh @@ -67,7 +67,7 @@ fi echo -e "${GRN}Configuring ${pureDesc}Nix shell for target '${TARGET}'...${RST}" 1>&2 # Save derivation from being garbage collected -${GIT_ROOT}/nix/scripts/gcroots.sh "shells.${TARGET}" +"${GIT_ROOT}/nix/scripts/gcroots.sh" "shells.${TARGET}" # ENTER_NIX_SHELL is the fake command used when `make shell` is run. # It is just a special string, not a variable, and a marker to not use `--run`. diff --git a/nix/scripts/source.sh b/nix/scripts/source.sh index a70f9a2c28..d8b2d06d05 100755 --- a/nix/scripts/source.sh +++ b/nix/scripts/source.sh @@ -25,7 +25,7 @@ main() { # Setup Nix if not available if [[ ! -d /nix ]]; then - ${GIT_ROOT}/nix/scripts/setup.sh + "${GIT_ROOT}/nix/scripts/setup.sh" fi # Load Nix profile diff --git a/nix/shells.nix b/nix/shells.nix index eb6227a3e0..9400376d6f 100644 --- a/nix/shells.nix +++ b/nix/shells.nix @@ -16,7 +16,7 @@ let node-sh = mkShell { shellHook = '' export STATUS_MOBILE_HOME=$(git rev-parse --show-toplevel) - $STATUS_MOBILE_HOME/nix/scripts/node_modules.sh ${pkgs.deps.nodejs-patched} + "$STATUS_MOBILE_HOME/nix/scripts/node_modules.sh" ${pkgs.deps.nodejs-patched} ''; }; diff --git a/scripts/build-android.sh b/scripts/build-android.sh index 63400001a6..8b8aa0be58 100755 --- a/scripts/build-android.sh +++ b/scripts/build-android.sh @@ -69,4 +69,4 @@ fi nixOpts+=("--arg" "config" "{${config}}") -${GIT_ROOT}/nix/scripts/build.sh targets.mobile.android.release "${nixOpts[@]}" +"${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.release "${nixOpts[@]}" diff --git a/scripts/generate-keystore.sh b/scripts/generate-keystore.sh index 0b3fc20151..0bf7df4f49 100755 --- a/scripts/generate-keystore.sh +++ b/scripts/generate-keystore.sh @@ -10,7 +10,7 @@ function property() { } function gradle_property() { - property ${GIT_ROOT}/android/gradle.properties ${1} + property "${GIT_ROOT}/android/gradle.properties" ${1} } function env_var_or_gradle_prop() { diff --git a/scripts/sign-android.sh b/scripts/sign-android.sh index 59b8c23eed..2a59cd45f8 100755 --- a/scripts/sign-android.sh +++ b/scripts/sign-android.sh @@ -9,7 +9,7 @@ function property() { } function gradle_property() { - property ${GIT_ROOT}/android/gradle.properties ${1} + property "${GIT_ROOT}/android/gradle.properties" ${1} } function env_var_or_gradle_prop() {