summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-12-18 22:45:02 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-12-18 22:45:02 +0100
commit36af99cee53fd99d425f0d44e681f5ea13e3974a (patch)
treee7773227a89e0a2f278092b5a8842961b7186a27
parent0c97c2124e83b0bcf8719a62ce3704602ee66c38 (diff)
downloadzig-playground-36af99cee53fd99d425f0d44e681f5ea13e3974a.tar.gz
zig-playground-36af99cee53fd99d425f0d44e681f5ea13e3974a.zip
setup: allow passing locating to already downloaded zig version
-rw-r--r--setup.fish31
1 files changed, 19 insertions, 12 deletions
diff --git a/setup.fish b/setup.fish
index 9bb4561..28e6f86 100644
--- a/setup.fish
+++ b/setup.fish
@@ -1,19 +1,26 @@
-curl -s https://ziglang.org/download/index.json -o index.json
-or exit 1
+if test -z $argv[1]
+ curl -s https://ziglang.org/download/index.json -o index.json
+ or exit 1
-set DLLINK (cat index.json | jq -r '.master ."x86_64-linux" .tarball')
-set SHASUM (cat index.json | jq -r '.master ."x86_64-linux" .shasum')
+ set DLLINK (cat index.json | jq -r '.master ."x86_64-linux" .tarball')
+ set SHASUM (cat index.json | jq -r '.master ."x86_64-linux" .shasum')
-rm -f index.json
+ rm -f index.json
-set TARBALL (echo $DLLINK | awk -F '/' '{ print $NF }')
-set ZIGDIR (echo $TARBALL | sed 's/.tar.xz//')
+ set TARBALL (echo $DLLINK | awk -F '/' '{ print $NF }')
+ set ZIGDIR (echo $TARBALL | sed 's/.tar.xz//')
-if ! test -d $ZIGDIR
- wget -q --show-progress --no-clobber $DLLINK
- and shasum -a 256 -c (echo "$SHASUM $TARBALL" | psub)
- and tar xf $TARBALL
- or exit 2
+ if ! test -d $ZIGDIR
+ wget -q --show-progress --no-clobber $DLLINK
+ and shasum -a 256 -c (echo "$SHASUM $TARBALL" | psub)
+ and tar xf $TARBALL
+ or exit 2
+ end
+else
+ set ZIGDIR $argv[1]
+
+ test -d $ZIGDIR
+ or exit 3
end
echo "SETUP $ZIGDIR"