diff options
Diffstat (limited to 'bin/fcard')
| -rwxr-xr-x | bin/fcard | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -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)) |