Compare commits

...

3 Commits

Author SHA1 Message Date
Case Duckworth f8a7f09627 Document some more
continuous-integration/drone/push Build is passing Details
2021-03-02 17:58:44 -06:00
Case Duckworth ca8db6208f Fix tiny bugs
The rubber ducky method works!!
2021-03-02 17:58:22 -06:00
Case Duckworth 41a1534ee0 Make shfmt happy
The (C-c) pissed it off for some reason .. and it's only on the upstairs machine..
2021-03-02 17:57:28 -06:00
1 changed files with 19 additions and 11 deletions

30
bollux
View File

@ -64,7 +64,7 @@ END
#
# See `log' for the available levels.
run() { # run COMMAND...
# I have to add a `trap' here for SIGINT (C-c) to work properly.
# I have to add a `trap' here for SIGINT to work properly.
trap bollux_quit SIGINT
log debug "$*"
"$@"
@ -372,17 +372,27 @@ uwellform() {
# directly from RFC 3986, Appendix B -- and if the URL provided doesn't match
# it, the function bails.
#
# `usplit' takes advantage ... [CONTINUE HERE]
# `usplit' takes advantage of bash's regex abilities: when the regex comparison
# operator `=~' is used, bash populates the array $BASH_REMATCH with the groups
# matched, and ${BASH_REMATCH[0]} is the entirety of the match. So `usplit'
# takes the matched URL, splits it using the regex, then assigns each part to an
# element of the url array NAME by using `printf -v', which prints to a
# variable.
usplit() { # usplit NAME:ARRAY URL:STRING
local re='^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?'
[[ $2 =~ $re ]] || return $?
# ShellCheck doesn't see that I'm using these variables in the `for'
# loop below, because I'm not technically using them /as/ variables, but
# as names to the variables. The ${!c} formation in the `printf' call
# below performs a reverse lookup on the name to get the actual data.
# shellcheck disable=2034
local scheme="${BASH_REMATCH[2]}" \
authority="${BASH_REMATCH[4]}" \
path="${BASH_REMATCH[5]}" \
query="${BASH_REMATCH[7]}" \
fragment="${BASH_REMATCH[9]}"
local url="${BASH_REMATCH[0]}" \
scheme="${BASH_REMATCH[2]}" \
authority="${BASH_REMATCH[4]}" \
path="${BASH_REMATCH[5]}" \
query="${BASH_REMATCH[7]}" \
fragment="${BASH_REMATCH[9]}"
# 0=url 1=scheme 2=authority 3=path 4=query 5=fragment
local i=1 c
@ -390,13 +400,11 @@ usplit() { # usplit NAME:ARRAY URL:STRING
if [[ "${!c}" || "$c" == path ]]; then
printf -v "$1[$i]" '%s' "${!c}"
else
# shellcheck disable=2059
printf -v "$1[$i]" "$UC_BLANK"
printf -v "$1[$i]" '%s' "$UC_BLANK"
fi
((i += 1))
done
# shellcheck disable=2059
printf -v "$1[0]" "$(ujoin "$1")" # inefficient I'm sure
printf -v "$1[0]" '%s' "$url"
}
ujoin() { # ujoin NAME:ARRAY