about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-10-09 14:25:27 -0400
committerZach DeCook <zachdecook@librem.one>2021-10-09 15:57:46 -0400
commit6ccd1b82b2eb316fd95bbf9333cc5ed5809b509a (patch)
tree9a7c62f972ff403341fb441fe890bf9d6d667a87
parent78b9951650925c50bc9e54030aa63b400ef7bcb1 (diff)
downloadswipeGuess-6ccd1b82b2eb316fd95bbf9333cc5ed5809b509a.tar.gz
scripts: try to make them pipe together better
it's important that the input program flushes the output
-rwxr-xr-xfirstComplete.sh6
-rwxr-xr-xswipeGuess.sh17
2 files changed, 16 insertions, 7 deletions
diff --git a/firstComplete.sh b/firstComplete.sh
index 0a75e88..de13a92 100755
--- a/firstComplete.sh
+++ b/firstComplete.sh
@@ -1,3 +1,5 @@
 #!/bin/sh
-read -r word
-sxmo_type.sh ${word:1}
+type=wtype
+while read -r word; do
+	test "${word:1}" && $type "${word:1}"
+done
diff --git a/swipeGuess.sh b/swipeGuess.sh
index 53fc4b4..f5f3225 100755
--- a/swipeGuess.sh
+++ b/swipeGuess.sh
@@ -3,15 +3,22 @@
 swipeToQuery(){
 	swipe=$1
 	printf '^'
-	printf ${swipe:0:2}
+	printf "${swipe:0:2}"
 	if test "${swipe:2}"; then
 		printf "${swipe:2}" |grep -o . | xargs printf '\?%s'
 	fi
 	printf '$'
 }
 
-wordlist="$2"
+query(){
+	swipe="$2"
+	wordlist="$1"
 
-query=$(swipeToQuery $1)
-echo "query: $query" > /dev/stderr
-grep $query "$2"
+	query=$(swipeToQuery $swipe)
+	#echo "query: $query" > /dev/stderr
+	grep $query "$wordlist"
+}
+
+while read -r line; do
+	test "$line" && query "$1" "$line" && printf '\n'
+done