summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepoch <epoch@thebackupbox.net>2020-05-01 15:59:08 -0500
committerepoch <epoch@thebackupbox.net>2020-05-01 15:59:08 -0500
commitb26efcc56e7389dfb550ab63ecc01aa176bf1fbf (patch)
tree8b554383e553063864d04201ab75a25a92406a1f
parent8ec0b3da94b3bbc18140bdea22488d51676d2634 (diff)
downloaduritools-b26efcc56e7389dfb550ab63ecc01aa176bf1fbf.tar.gz
uritools-b26efcc56e7389dfb550ab63ecc01aa176bf1fbf.zip
changed up how it tries to grep port and protol info out of /etc/services a bit
-rwxr-xr-xuristart4
1 files changed, 2 insertions, 2 deletions
diff --git a/uristart b/uristart
index 17a5af9..2491f81 100755
--- a/uristart
+++ b/uristart
@@ -22,7 +22,7 @@ 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
- proto="$(grep ^"$scheme"'[\t ]' /etc/services | tr -s '\t ' | cut -f2 | cut -d/ -f1 | head -n1)"
+ proto="$(grep ^"$scheme"'\s' /etc/services | tr ' ' '\t' | tr -s '\t ' | cut -f2 | cut -d/ -f2 | head -n1)"
if [ ! "$proto" ]; then
proto=tcp
fi
@@ -35,7 +35,7 @@ fi
### if they do not have srv records, fall-back to /etc/services
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: /') \
+ <(grep ^"$scheme"'\s' /etc/services | tr ' ' '\t' | tr -s '\t' | cut -f2 | cut -d/ -f1 | head -n1 | sed 's/^/port: /') \
| urijoin 2>/dev/null)"
printf "getent modified uri: %s\n" "$uri" >&2
fi