From f4400c6410f4b932eb738760996e0dcc271157f1 Mon Sep 17 00:00:00 2001 From: cos Date: Thu, 2 Dec 2021 10:35:51 +0100 Subject: Verify dependencies for fetch_input are available --- bin/fetch_input.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'bin') diff --git a/bin/fetch_input.sh b/bin/fetch_input.sh index 6b27931..d3a96ec 100755 --- a/bin/fetch_input.sh +++ b/bin/fetch_input.sh @@ -1,4 +1,5 @@ #!/bin/sh -eu +# vim: sw=2 et COOKIES="${HOME}/.adventofcode.json" @@ -11,6 +12,20 @@ MODE="wget" # https://stackoverflow.com/q/21919156/how-do-i-copy-cookies-from-chrome SESSION=$(jq < "${COOKIES}" '."session-cookie"') +check_dependency_availability() { + local bin + + for bin in 'elinks' \ + 'jq' \ + 'wget' + do + if ! which "${bin}" >/dev/null; then + echo "Missing dependency: ${bin}" >&2 + exit 1 + fi + done +} + concat() { local part @@ -26,6 +41,8 @@ authenticated_wget() { "${@}" } +check_dependency_availability + if [ "${MODE}" = 'wget' ]; then cd "${YEAR}" cd 'rust' -- cgit v1.2.3