diff options
| author | Zach DeCook <zachdecook@librem.one> | 2021-10-11 16:40:25 -0400 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2021-10-11 16:40:25 -0400 |
| commit | 63bd2aa6b7d35484bf561fab91247a7513df22dd (patch) | |
| tree | ee3db629dabe4666391b7fc9dd957b02eacfd951 /swipeGuess.sh | |
| parent | b5f1684628e292d44ca00921900402258422b227 (diff) | |
| download | swipeGuess-63bd2aa6b7d35484bf561fab91247a7513df22dd.tar.gz | |
swipeGuess: allow to use directory instead of file
Diffstat (limited to 'swipeGuess.sh')
| -rwxr-xr-x | swipeGuess.sh | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/swipeGuess.sh b/swipeGuess.sh index 092c1ee..857f792 100755 --- a/swipeGuess.sh +++ b/swipeGuess.sh @@ -1,5 +1,7 @@ #!/bin/sh +source "$(dirname "$0")/functions.sh" + swipeToQuery(){ swipe=$(echo "$1" | tr -d "'.\*\"\\^$\(\)") printf '^' @@ -13,11 +15,18 @@ swipeToQuery(){ query(){ swipe="$2" wordlist="$1" + wordfile="$wordlist" + if test -d "$wordlist"; then + wordfile=/dev/null + fl=$(firstLetter "$swipe") + ll=$(lastLetter "$swipe") + test -f "$wordlist/$fl$ll" && wordfile="$wordlist/$fl$ll" + fi query=$(swipeToQuery "$swipe") echo "query: $query" > /dev/stderr # -m 1: just give first result - grep -m 1 "$query" "$wordlist" + grep -m 1 "$query" "$wordfile" } while read -r line; do |
