diff options
author | Delan Azabani <dazabani@igalia.com> | 2025-02-21 16:21:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-21 08:21:50 +0000 |
commit | 14db055d4618ccd232e04e9b35b3c3a49e3d6c3f (patch) | |
tree | bb5312c4f5fcd42d84668c17b767734238c8c55f /mach | |
parent | 9c8a47e99300a0ce70683dcb3b614d1e7588a032 (diff) | |
download | servo-14db055d4618ccd232e04e9b35b3c3a49e3d6c3f.tar.gz servo-14db055d4618ccd232e04e9b35b3c3a49e3d6c3f.zip |
Fix mach argument quoting on NixOS (#35573)
This patch makes mach shell-quote its arguments when rerunning itself
with `nix-shell`, so that spaces and other special characters are
handled correctly.
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Diffstat (limited to 'mach')
-rwxr-xr-x | mach | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -15,6 +15,14 @@ run_in_nix_if_needed() { if { [ -f /etc/NIXOS ] || [ -n "${MACH_USE_NIX}" ]; } && [ -z "${IN_NIX_SHELL}" ]; then EXTRA_NIX_ARGS=${SERVO_ANDROID_BUILD:+'--arg buildAndroid true'} + + # `nix-shell` needs the whole command passed as a single argument, so the arguments need + # to be shell-quoted. Rotate through the arguments, replacing them with quoted versions. + for arg in "$@"; do + set -- "$@" "$(printf \%q "$1")" + shift + done + echo "NOTE: Entering nix-shell ${MACH_DIR}/shell.nix" exec nix-shell "${MACH_DIR}/shell.nix" $EXTRA_NIX_ARGS --run "$*" else |