summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-12-27 18:45:14 +0000
committerdavidovski <david@davidovski.xyz>2023-12-27 18:45:14 +0000
commit8788e6bd8023dc4b8fe24f22e0bfd85e325658c5 (patch)
tree0644f3bc6a439132893c40f4265e58ee8a3eb6ee
parent9ff1c1dba2657557d1d6f5dbf939eb45257a14d4 (diff)
use shuf correctly to output random lines
-rwxr-xr-xtypr.sh12
1 files changed, 1 insertions, 11 deletions
diff --git a/typr.sh b/typr.sh
index 75003be..800b7f1 100755
--- a/typr.sh
+++ b/typr.sh
@@ -114,18 +114,8 @@ typr_show_results () {
}
typr_generate_text () {
- words="$(printf "%s " $words | shuf)"
wordcount=100
-
- set -- $words
- text=""
-
- i=0
- while [ "$i" -lt "$wordcount" ]; do
- text="$1 $text"
- shift
- i=$((i+1))
- done
+ text="$(printf "%s\n" $words | shuf -r -n $wordcount | xargs printf "%s ")"
text="${text% }"
}