summaryrefslogtreecommitdiff
path: root/urigetline
diff options
context:
space:
mode:
authorepoch <epoch@thebackupbox.net>2020-04-20 03:33:21 -0500
committerepoch <epoch@thebackupbox.net>2020-04-20 03:33:21 -0500
commit8ec0b3da94b3bbc18140bdea22488d51676d2634 (patch)
tree1aeb045d712767b117bea412e65348897eefa0e5 /urigetline
parent3e23d5631b7664de5a78aaaac211bff357152c00 (diff)
downloaduritools-8ec0b3da94b3bbc18140bdea22488d51676d2634.tar.gz
uritools-8ec0b3da94b3bbc18140bdea22488d51676d2634.zip
more of the breaking-change. code to get the line moved to external program so it can be rewritten easier. copy_start_nevermind.sh uses it now. cleaned up Makefile styling.
Diffstat (limited to 'urigetline')
-rwxr-xr-xurigetline25
1 files changed, 25 insertions, 0 deletions
diff --git a/urigetline b/urigetline
new file mode 100755
index 0000000..81e28c9
--- /dev/null
+++ b/urigetline
@@ -0,0 +1,25 @@
+#!/bin/bash
+uri="$1"
+### old way.
+# line="$(grep "^${scheme}:" ~/.config/uristart.conf | cut -d: -f2- | sed 's/^[ \t]*//g' | sed 's/\\/\\\\/g')"
+
+### fancy way.
+cat ~/.config/uristart.conf \
+ | while read -r l;do
+ uritmp="$uri"
+ uritmp="$(printf "%s\n" "$l" \
+ | cut -d: -f1 \
+ | tr ' ' '\n' \
+ | paste '-d ' - - \
+ | while read -r a b;do
+ uritmp="$(printf "%s\n" "${uritmp}" | urimatch "$a" "$b")"
+ printf "%s\n" "$uritmp"
+ done | tail -n1)"
+ if [ "$uritmp" ];then
+ printf '%s\n' "$l"
+ break
+ fi
+ done \
+ | cut -d: -f2- \
+ | sed 's/^[ \t]*//g' \
+ | sed 's/\\/\\\\/g'