Skip to content

Instantly share code, notes, and snippets.

@MadratJerry
Last active February 21, 2024 16:56
Show Gist options
  • Save MadratJerry/5748ab45fa8ac2034e198d023eb336e5 to your computer and use it in GitHub Desktop.
Save MadratJerry/5748ab45fa8ac2034e198d023eb336e5 to your computer and use it in GitHub Desktop.
Find the latest rust nightly version with rls-preview
#!/bin/bash
MAC=false
date -r "$now" +%Y-%m-%d &> /dev/null
if [ "$?" -ne "0" ]; then echo "LINUX"; MAC=false; else echo 'MAC'; MAC=true; fi
now=`date +%s`
while true
do
if [ "$MAC" == "true" ]; then data=`date -r "$now" +%Y-%m-%d`; else data=`date -d @"$now" +%Y-%m-%d`; fi
echo $data
str=`curl -s https://static.rust-lang.org/dist/$data/channel-rust-nightly.toml | grep rls-preview`
if [ "$str" != "" ]; then echo "Bingo!"; break; fi
now=$(($now-86400))
done
@azriel91
Copy link

azriel91 commented Sep 5, 2018

btw, Linux thinks it's a Mac unless you move the "now=date +%s" line above line 3

@AndreasOlofsson
Copy link

Big thanks for this script, it does however seem to return false positives as rls-preview may be available for a certain nightly but not for your specific target. I quickly fixed it with the following patch, maybe you or someone else wants to write some stuff to actually detect the current system's target string.

--- find-rls-preview.sh	2019-04-05 12:33:59.459154159 +0200
+++ find-rls-preview.sh	2019-04-05 12:32:24.553194878 +0200
@@ -12 +12 @@
-  str=`curl -s https://static.rust-lang.org/dist/$data/channel-rust-nightly.toml | grep rls-preview`
+  str=`curl -s https://static.rust-lang.org/dist/$data/channel-rust-nightly.toml | grep -A 1 rls-preview.target.x86_64-unknown-linux-gnu | grep "available = true"`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment