aboutsummaryrefslogtreecommitdiffstats
path: root/bin/fcard
diff options
context:
space:
mode:
Diffstat (limited to 'bin/fcard')
-rwxr-xr-xbin/fcard21
1 files changed, 10 insertions, 11 deletions
diff --git a/bin/fcard b/bin/fcard
index e4a851d..23edd30 100755
--- a/bin/fcard
+++ b/bin/fcard
@@ -20,17 +20,16 @@ grabbag() {
size="$(wc -l)"
oldlist="$(cat)"
newlist=""
- a=0
- while a="$size"; do
- z="$(($(rand)%a))"
- newlist="$(cut -d ' ' -f "$z"<<EOF
-$oldlist
-EOF
-) "
- oldlist="$(cut -d ' ' -f "-$((z-1)),$((z+1))-" <<EOF
-$oldlist
-EOF
-)"
+ while [ ${a:="$size"} -gt 0]; do
+ z="$(($(rand)%a))"
+ newlist="$(cut -d ' ' -f "$z"<<-EOF
+ $oldlist
+ EOF
+ ) "
+ oldlist="$(cut -d ' ' -f "-$((z-1)),$((z+1))-" <<-EOF
+ $oldlist
+ EOF
+ )"
# add z to space-delim'd list
# remove from input list
a=$((a-1))