diff options
author | Case Duckworth | 2020-05-23 19:49:20 -0500 |
---|---|---|
committer | Case Duckworth | 2020-05-23 19:49:20 -0500 |
commit | bcc28cfae840f6657522f1e7037bfc899318a81e (patch) | |
tree | 561beeb47ee582d4193af3a26a2b709c7046a15a | |
parent | Fix redirects (diff) | |
download | bollux-bcc28cfae840f6657522f1e7037bfc899318a81e.tar.gz bollux-bcc28cfae840f6657522f1e7037bfc899318a81e.zip |
Add option parsing and change order of operations
-rwxr-xr-x | bollux | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/bollux b/bollux index b319e9d..079c83b 100755 --- a/bollux +++ b/bollux | |||
@@ -347,18 +347,26 @@ bollux() { | |||
347 | request "$URL" | handle "$URL" | 347 | request "$URL" | handle "$URL" |
348 | } | 348 | } |
349 | 349 | ||
350 | process_cmdline() { | ||
351 | while getopts :hL: OPT; do | ||
352 | case "$OPT" in | ||
353 | h) bollux_usage ;; | ||
354 | L) LOGL="$OPTARG" ;; | ||
355 | :) die 1 "Option -$OPTARG requires an argument" ;; | ||
356 | *) die 1 "Unknown option: -$OPTARG" ;; | ||
357 | esac | ||
358 | done | ||
359 | } | ||
360 | |||
350 | bollux_setup() { | 361 | bollux_setup() { |
351 | mkfifo .resource | 362 | trap bollux_cleanup INT QUIT EXIT |
352 | trap bollux_cleanup INT QUIT TERM EXIT | ||
353 | } | 363 | } |
354 | 364 | ||
355 | bollux_cleanup() { | 365 | bollux_cleanup() { |
356 | echo | 366 | echo |
357 | rm -f .resource | ||
358 | } | 367 | } |
359 | 368 | ||
360 | if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then | 369 | if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then |
361 | set -euo pipefail # strict mode | ||
362 | # requirements here -- so they're only checked once | 370 | # requirements here -- so they're only checked once |
363 | require gawk | 371 | require gawk |
364 | require dd | 372 | require dd |
@@ -366,6 +374,9 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then | |||
366 | require openssl | 374 | require openssl |
367 | require sed | 375 | require sed |
368 | 376 | ||
377 | bollux_setup | ||
378 | |||
369 | bollux "$@" | 379 | bollux "$@" |
370 | echo | 380 | |
381 | bollux_cleanup | ||
371 | fi | 382 | fi |