summaryrefslogtreecommitdiff
path: root/uristart
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2020-01-21 10:41:50 -0600
committerepoch <epoch@hacking.allowed.org>2020-01-21 10:41:50 -0600
commitcdf03f340e6117f4384967d0d946fe8fd4dc9dd5 (patch)
tree46e2a22fc6a27abce9e555ad45cf4dfc9498d8c2 /uristart
parent9dcf098ebc512b929b1f55fca4a9144986ad042f (diff)
downloaduritools-cdf03f340e6117f4384967d0d946fe8fd4dc9dd5.tar.gz
uritools-cdf03f340e6117f4384967d0d946fe8fd4dc9dd5.zip
added ability to --check what uristart would do, then noticed I wasn't clipping ALL of the leading whitespace, so fixed that.
Diffstat (limited to 'uristart')
-rwxr-xr-xuristart17
1 files changed, 14 insertions, 3 deletions
diff --git a/uristart b/uristart
index 3acf785..b3feb81 100755
--- a/uristart
+++ b/uristart
@@ -8,9 +8,16 @@
##might have to configure me.
ASKUSER="dmenu -p"
+if [ "$1" = "--check" ];then
+ check=1
+ shift
+else
+ check=0
+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="$(grep "^${scheme}:" ~/.config/uristart.conf | cut -d: -f2- | sed 's/^[ \t]*//g' | sed 's/\\/\\\\/g')"
### 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
@@ -33,7 +40,7 @@ if printf "%s\n" "$uri" | urimatch nP >/dev/null;then #if we *still* don't have
fi
### ask the user for a pipeline for starting these URIs if there isn't a pipeline already in the config.
-echo "the uri we're using: $uri"
+echo "the uri we're using: $uri" >&2
if [ "$line" = "" ];then
line="$(printf "" | $ASKUSER "protocol scheme (${scheme}) not configured yet. enter new pipeline to use:")"
if [ "$line" = "" ];then
@@ -53,4 +60,8 @@ if ! cut '-d ' -f1 ~/.cache/uristart.log | grep -Fx "$uri" 2>&1 >/dev/null;then
fi
### do the magic
-eval "$(printf "%s\n" "$uri" | sed 's/'\''/'\''\\'\'''\''/g' | uriprintf "$line")"
+if [ "$check" ];then
+ printf "%s\n" "$(printf "%s\n" "$uri" | sed 's/'\''/'\''\\'\'''\''/g' | uriprintf "$line")"
+else
+ eval "$(printf "%s\n" "$uri" | sed 's/'\''/'\''\\'\'''\''/g' | uriprintf "$line")"
+fi