-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: uritools
action: commit
revision:
path_from:
revision_from: 8ec0b3da94b3bbc18140bdea22488d51676d2634:
path_to:
revision_to:

git.thebackupbox.net

uritools

git://git.thebackupbox.net/uritools

commit 8ec0b3da94b3bbc18140bdea22488d51676d2634
Author: epoch <epoch@thebackupbox.net>
Date:   Mon Apr 20 03:33:21 2020 -0500

    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.

diff --git a/Makefile b/Makefile

index f8079ce405fc8e84e33beb2ed26f4f427d2dd635..

index ..b6e3ab8067bb0dd411294bdc89fc850907412c41 100644

--- a/Makefile
+++ b/Makefile
@@ -21,17 +21,18 @@ clean:
 	rm -f *.o

 install: all
-	install urimatch $(PREFIX)/bin/urimatch
-	install uricut $(PREFIX)/bin/uricut
-	install urijoin $(PREFIX)/bin/urijoin
-	install uricmp $(PREFIX)/bin/uricmp
-	install uristart $(PREFIX)/bin/uristart
-	install uriprintf $(PREFIX)/bin/uriprintf
-	install uriunescape $(PREFIX)/bin/uriunescape
-	install uriescape $(PREFIX)/bin/uriescape
-	install urilaunch $(PREFIX)/bin/urilaunch
-	install search $(PREFIX)/bin/search
-	install getsrv $(PREFIX)/bin/getsrv
-	install urititle $(PREFIX)/bin/urititle
+	install -t $(PREFIX)/bin urimatch
+	install -t $(PREFIX)/bin uricut
+	install -t $(PREFIX)/bin urijoin
+	install -t $(PREFIX)/bin uricmp
+	install -t $(PREFIX)/bin uristart
+	install -t $(PREFIX)/bin uriprintf
+	install -t $(PREFIX)/bin uriunescape
+	install -t $(PREFIX)/bin uriescape
+	install -t $(PREFIX)/bin urilaunch
+	install -t $(PREFIX)/bin search
+	install -t $(PREFIX)/bin getsrv
+	install -t $(PREFIX)/bin urititle
+	install -t $(PREFIX)/bin urigetline
 	install -t $(PREFIX)/bin copy_start_nevermind.sh
 	install -t $(PREFIX)/bin choose
diff --git a/copy_start_nevermind.sh b/copy_start_nevermind.sh

index ec8f1020f51b4c45a1c91753b7642738229b0c70..

index ..cae566815ac828e34bb7820e6bd0736fbbd4d356 100755

--- a/copy_start_nevermind.sh
+++ b/copy_start_nevermind.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 scheme="$(uricut -s <<< "$1")"
 selection="$(printf "%s\ncopy\nstart\nnevermind\n" "$(printf "%s\n" "$1" | uricut | grep -v '^whole')" \
-            | choose "$(printf "uri: '%s'\nwill be ran with: %s\n" "$1" "$(grep "^${scheme}:" ~/.config/uristart.conf | tr -s '\t' | cut -f2- )" )")"
+            | choose "$(printf "uri: '%s'\nwill be ran with: %s\n" "$1" "$(urigetline "$1")" )")"
 echo "$selection"
 if [ "$selection" = "copy" ];then
   printf "%s" "$1" | xclip -i
diff --git a/urigetline b/urigetline
new file mode 100755
index 0000000000000000000000000000000000000000..81e28c9fff04f476cd34ea290507fe0f3c6b44a2
--- /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'
diff --git a/uristart b/uristart

index d36764ff021c86848f280e7a7235bb93abe9498c..

index ..17a5af9e75f08f0e72fec418d064249f722718d9 100755

--- a/uristart
+++ b/uristart
@@ -17,29 +17,8 @@ fi

 uri="${1}"
 scheme="$(printf "%s\n" "$uri" | uricut -s)"
-#line="$(grep "^${scheme}:" ~/.config/uristart.conf | cut -d: -f2- | sed 's/^[ \t]*//g' | sed 's/\\/\\\\/g')"

-line="$(
-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'
-)"
+line="$(urigetline "$uri")"

 ### if we do not have a port, we are going to try to get it from their srv records.
 if printf "%s\n" "$uri" | urimatch nP >/dev/null;then
@@ -49,7 +28,7 @@ if printf "%s\n" "$uri" | urimatch nP >/dev/null;then
   fi
   uri="$(cat <(printf "%s\n" "$uri" | uricut) \
              <(getsrv $(printf "%s\n" "$uri" | uriprintf '%s '"$proto"' %d' | cut -d+ -f2-) 2>&- | tr ':' ' ' | sed 's/ /_port: /' | sed 's/^/domain: /' | tr _ '\n') \
-          | urijoin)"
+          | urijoin 2>/dev/null)"
   printf "srv (%s) modified uri: %s\n" "$proto" "$uri" >&2
 fi

@@ -57,7 +36,7 @@ fi
 if printf "%s\n" "$uri" | urimatch nP >/dev/null;then #if we *still* don't have a port
   uri="$(cat <(printf "%s\n" "$uri" | uricut) \
              <(grep ^"$scheme"'[\t ]' /etc/services | tr -s '\t ' | cut -f2 | cut -d/ -f1 | head -n1 | sed 's/^/port: /') \
-          | urijoin)"
+          | urijoin 2>/dev/null)"
   printf "getent modified uri: %s\n" "$uri" >&2
 fi

diff --git a/uristart.conf.example b/uristart.conf.example

index 27fab791216a2a4e9348bf01b8b68c6d27e087cb..

index ..53fc08b8140825830b582f17c480ab0e0ae2093b 100644

--- a/uristart.conf.example
+++ b/uristart.conf.example
@@ -1,8 +1,8 @@
 ### uristart will escape only single-quotes in the url parts.
 ###  so place them inside single-quotes when creating handler pipelines. or else!
 ### (if you're given a bad link someone might be able to run shell commands)
-finger:		printf "%%s\r\n" '%p' | ncat '%d' 79 | tr -d '\r' | xmessage -file -
-whois:		whois "$(printf '%%s\\\\n' '%d' | sed 's/^..*$/-h/')" '%d' '%p' | xmessage -file -
-irc:		x-terminal-emulator -e irssi -c '%d' -p '%P'
-http:		firefox --new-tab '%U'
-DEFAULT:	xdg-open '%U'
+s finger:		printf "%%s\r\n" '%p' | ncat '%d' 79 | tr -d '\r' | xmessage -file -
+s whois:		whois "$(printf '%%s\\\\n' '%d' | sed 's/^..*$/-h/')" '%d' '%p' | xmessage -file -
+s irc:		x-terminal-emulator -e irssi -c '%d' -p '%P'
+s http:		firefox --new-tab '%U'
+s DEFAULT:	xdg-open '%U'

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 17:14:37 2024