on master help sign in
nix-bootstrap.sh: fix shellcheck warnings

It also changes how the arguments are being passed around.

commit567291233682e562aee1a146c7fc226930a4ef00 authorzimbatm <zimbatm@zimbatm.com> dateThu 22 Oct 2020, 15:15 (6 years ago) parent565770f
1 file changed+13−13
nix-bootstrap.sh+13−13
nix-bootstrap.sh+13−13
@@ -1,35 +1,35 @@
11#!/bin/sh
22
3−cmd=sh
4−if ! [ $# -eq 0 ]; then
5− cmd=$@
3+if [ $# -gt 0 ]; then
4+ set -- sh
65fi
76
87# should download this in the future
98# but the mirror is down
10−proot=`dirname $0`/proot-`uname -p`
9+proot=$(dirname "$0")/proot-$(uname -p)
1110export PROOT_NO_SECCOMP=1
1211
1312nixdir=$HOME/.nix
1413
1514OLD_NIX_PATH=$NIX_PATH
16−if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi
17−if ! [ -z "$OLD_NIX_PATH" ]; then NIX_PATH="$OLD_NIX_PATH"; fi
15+# shellcheck disable=SC1090
16+if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh"; fi
17+if [ -n "$OLD_NIX_PATH" ]; then NIX_PATH="$OLD_NIX_PATH"; fi
1818
1919if [ -z "$IN_PROOT" ]; then
2020 export IN_PROOT=1
2121
22− if ! [ -d $nixdir ]; then
23− mkdir -p $nixdir
22+ if ! [ -d "$nixdir" ]; then
23+ mkdir -p "$nixdir"
2424 s=$(mktemp)
25− curl https://nixos.org/nix/install -o $s
26− $proot -b $nixdir:/nix $0 sh $s
25+ curl https://nixos.org/nix/install -o "$s"
26+ $proot -b "$nixdir:/nix" "$0" sh "$s"
2727 fi
2828
29− $proot -b $nixdir:/nix $0 $cmd
29+ $proot -b "$nixdir:/nix" "$0" "$@"
3030
3131 export IN_PROOT=
3232 exit
33−elif ! [ $# -eq 0 ]; then
34− exec $cmd
33+elif [ $# -gt 0 ]; then
34+ exec "$@"
3535fi