about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2020-06-02 21:07:46 -0500
committerCase Duckworth2020-06-02 21:07:46 -0500
commit2266f55681f372ae6aca17f70885e5e3ccd9094a (patch)
tree87dda535bdcf6e0e1ae3db8fc2f816dd74858985
parentRemove iconv dash (diff)
downloadbollux-2266f55681f372ae6aca17f70885e5e3ccd9094a.tar.gz
bollux-2266f55681f372ae6aca17f70885e5e3ccd9094a.zip
Reimplement extract_links in bash
-rwxr-xr-xbollux26
1 files changed, 13 insertions, 13 deletions
diff --git a/bollux b/bollux index cdd98c9..7ed4ae1 100755 --- a/bollux +++ b/bollux
@@ -621,19 +621,19 @@ select_url() {
621} 621}
622 622
623extract_links() { 623extract_links() {
624 gawk ' 624 local url alt
625 /^=>/ { 625 while read -r line; do
626 sub(/=>[[:space:]]*/,"") 626 if [[ "$line" =~ ^=\>[[:space:]]*([^[:space:]]+)([[:space:]]+(.*))?$ ]]; then
627 if ($2) { 627 url="${BASH_REMATCH[1]}"
628 rest="" 628 alt="${BASH_REMATCH[3]}"
629 for (i=2;i<=NF;i++) { 629
630 rest=rest (rest?" ":"")$i 630 if [[ "$alt" ]]; then
631 } 631 printf '%s \e[34m(%s)\e[0m\n' "$url" "$alt"
632 printf "%s (\033[34m%s\033[0m)\n", $1, rest 632 else
633 } else { 633 printf '%s\n' "$url"
634 printf "%s\n", $1 634 fi
635 } 635 fi
636 }' 636 done
637} 637}
638 638
639download() { 639download() {