You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ABS is a programming language that works best when you're scripting on
your terminal. It tries to combine the elegance of languages
such as Python, or Ruby with the convenience of Bash.
tz = `cat /etc/timezone`
continent, city = tz.split("/")
echo("Best city in the world?")
selection = stdin()
if selection == city {
echo("You might be biased...")
}
See it in action:
Let's try to fetch our IP address and print the sum of its
parts if it's higher than 100. Here's how you do it
in Bash:
# Simple program that fetches your IP and sums it up
RES=$(curl -s 'https://api.ipify.org?format=json'||"ERR")if [ "$RES"="ERR" ];thenecho"An error occurred"exit 1
fi
IP=$(echo $RES| jq -r ".ip")
IFS=. read first second third fourth <<EOF${IP##*-}EOF
total=$((first + second + third + fourth))if [ $total-gt 100 ];thenecho"The sum of [$IP] is a large number, $total."fi
And here's the same code in ABS:
# Simple program that fetches your IP and sums it up
res = `curl -s 'https://api.ipify.org?format=json'`if!res.ok {
echo("An error occurred: %s", res)
exit(1)
}
ip = res.json().ip
total = ip.split(".").map(int).sum()
if total > 100 {
echo("The sum of [$ip] is a large number, $total.")
}
Wondering how to run this code? Grab the latest
release and run: