Skip to content

Commit 14db055

Browse files
authored
Fix mach argument quoting on NixOS (servo#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 <[email protected]>
1 parent 9c8a47e commit 14db055

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mach

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
run_in_nix_if_needed() {
1616
if { [ -f /etc/NIXOS ] || [ -n "${MACH_USE_NIX}" ]; } && [ -z "${IN_NIX_SHELL}" ]; then
1717
EXTRA_NIX_ARGS=${SERVO_ANDROID_BUILD:+'--arg buildAndroid true'}
18+
19+
# `nix-shell` needs the whole command passed as a single argument, so the arguments need
20+
# to be shell-quoted. Rotate through the arguments, replacing them with quoted versions.
21+
for arg in "$@"; do
22+
set -- "$@" "$(printf \%q "$1")"
23+
shift
24+
done
25+
1826
echo "NOTE: Entering nix-shell ${MACH_DIR}/shell.nix"
1927
exec nix-shell "${MACH_DIR}/shell.nix" $EXTRA_NIX_ARGS --run "$*"
2028
else

0 commit comments

Comments
 (0)