on master help sign in
Quote properly in nix-run.sh
5ba831bMatthew Bauer
nix-run.sh+10−10
@@ -18,7 +18,7 @@ if [ -z "$1" ]; then
18 exit 1
18 exit 1
19fi
19fi
20
20
21−pkg=$1
21+pkg="$1"
22shift
22shift
23
23
24# A second argument will provide a hint to run
24# A second argument will provide a hint to run
@@ -31,7 +31,7 @@ fi
31
31
32expr="with import <nixpkgs> {}; let x = ($pkg); in x"
32expr="with import <nixpkgs> {}; let x = ($pkg); in x"
33path=$(nix-instantiate --no-gc-warning -E "$expr")
33path=$(nix-instantiate --no-gc-warning -E "$expr")
34−out=$(nix-store --no-gc-warning -r $path)
34+out=$(nix-store --no-gc-warning -r "$path")
35
35
36if [ -z "$out" ]; then
36if [ -z "$out" ]; then
37 >&2 echo "Could not evaluate $pkg to a Nix drv."
37 >&2 echo "Could not evaluate $pkg to a Nix drv."
@@ -43,7 +43,7 @@ run_darwin_app () {
43 dir="$1"
43 dir="$1"
44 shift
44 shift
45
45
46− open -a "$dir" --args $@
46+ open -a "$dir" --args "$@"
47}
47}
48
48
49# Run FILE as a Freedesktop application
49# Run FILE as a Freedesktop application
@@ -70,18 +70,18 @@ run_bin () {
70 file="$1"
70 file="$1"
71 shift
71 shift
72
72
73− $file $@
73+ "$file" "$@"
74}
74}
75
75
76if [ -x "$out/nix-support/run" ]; then
76if [ -x "$out/nix-support/run" ]; then
77− run_bin "$out/nix-support/run" $@
77+ run_bin "$out/nix-support/run" "$@"
78elif [ -x "$out/bin/run" ]; then
78elif [ -x "$out/bin/run" ]; then
79− run_bin "$out/bin/run" $@
79+ run_bin "$out/bin/run" "$@"
80elif [ "$(uname)" = Darwin ] && [ -d "$out/Applications/$name.app" ]; then
80elif [ "$(uname)" = Darwin ] && [ -d "$out/Applications/$name.app" ]; then
81− run_darwin_app "$out/Applications/$name.app" $@
81+ run_darwin_app "$out/Applications/$name.app" "$@"
82elif [ "$(uname)" = Darwin ] && [ -d $out/Applications/*.app ]; then
82elif [ "$(uname)" = Darwin ] && [ -d $out/Applications/*.app ]; then
83 for f in $out/Applications/*.app; do
83 for f in $out/Applications/*.app; do
84− run_darwin_app "$f" $@
84+ run_darwin_app "$f" "$@"
85 done
85 done
86elif [ -f "$out/share/applications/$name.desktop" ]; then
86elif [ -f "$out/share/applications/$name.desktop" ]; then
87 run_linux_desktop_app "$out/share/applications/$name.desktop" $@
87 run_linux_desktop_app "$out/share/applications/$name.desktop" $@
@@ -90,10 +90,10 @@ elif [ -d $out/share/applications ]; then
90 run_linux_desktop_app "$f"
90 run_linux_desktop_app "$f"
91 done
91 done
92elif [ -x "$out/bin/$name" ]; then
92elif [ -x "$out/bin/$name" ]; then
93− run_bin "$out/bin/$name" $@
93+ run_bin "$out/bin/$name" "$@"
94elif [ -d "$out/bin" ]; then
94elif [ -d "$out/bin" ]; then
95 for bin in $out/bin/*; do
95 for bin in $out/bin/*; do
96− run_bin "$bin" $@
96+ run_bin "$bin" "$@"
97 done
97 done
98else
98else
99 >&2 echo "Cannot find a way to run path $out."
99 >&2 echo "Cannot find a way to run path $out."