From 2541587957c2ae00bdb63b7361ae6b7c66d71c90 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 30 Dec 2019 07:51:50 -0500 Subject: slack: Support -, rewrite perl stuff in sed --- slack | 74 ++++++++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/slack b/slack index d3e2e7d..8f8b644 100755 --- a/slack +++ b/slack @@ -5,9 +5,9 @@ # Author: B. Watson (yalhcru at gmail) # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details. -# Unfortunately we can't use get with this form. Well, we can, +# Unfortunately we can't use GET with this form. Well, we can, # except the checkboxes for "search sets" don't work. So it has -# to be a post request, which means this elvis depends on wget. I +# to be a POST request, which means this elvis depends on wget. I # suppose it could support curl instead (or in addition) but I don't # see the point. @@ -15,9 +15,20 @@ . surfraw || exit 1 -if [ "$( type -p wget )" = "" ]; then - err "wget is required for this. please install it." -fi +check_bins() { + local i missing + for i in "$@"; do + if [ -z "$( type -p $i )" ]; then + warn "required external binary $i not found on PATH." + missing="${missing}$i " + fi + done + if [ -n "$missing" ]; then + err "please install the missing binaries, or adjust PATH (currently \"$PATH\")" + fi +} + +url="https://packages.slackware.com/" get_slack_ver() { local ver sitevers i @@ -34,11 +45,12 @@ get_slack_ver() { return fi - # now check the site, make sure it's a supported version - # TODO: rewrite to use sed or awk? maybe not that big a deal. + # now check the site, make sure it's a supported version. this would + # be easier in perl, but I wanna keep external deps to a minimum. sitevers="$( - wget -qO- "https://packages.slackware.com" | \ - perl -ne 'print "$1 " while (/