From bcc28cfae840f6657522f1e7037bfc899318a81e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 23 May 2020 19:49:20 -0500 Subject: Add option parsing and change order of operations --- bollux | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bollux b/bollux index b319e9d..079c83b 100755 --- a/bollux +++ b/bollux @@ -347,18 +347,26 @@ bollux() { request "$URL" | handle "$URL" } +process_cmdline() { + while getopts :hL: OPT; do + case "$OPT" in + h) bollux_usage ;; + L) LOGL="$OPTARG" ;; + :) die 1 "Option -$OPTARG requires an argument" ;; + *) die 1 "Unknown option: -$OPTARG" ;; + esac + done +} + bollux_setup() { - mkfifo .resource - trap bollux_cleanup INT QUIT TERM EXIT + trap bollux_cleanup INT QUIT EXIT } bollux_cleanup() { echo - rm -f .resource } if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then - set -euo pipefail # strict mode # requirements here -- so they're only checked once require gawk require dd @@ -366,6 +374,9 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then require openssl require sed + bollux_setup + bollux "$@" - echo + + bollux_cleanup fi -- cgit 1.4.1-21-gabe81