|
From: | John Kearney |
Subject: | Re: [Help-bash] Adding missing bash features for safely re-usable bash code |
Date: | Tue, 09 Apr 2013 10:10:36 +0200 |
User-agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 |
Am 09.04.2013 08:08, schrieb Pierre
Gaston:
No need for eval here you can do as its an integer value you can do the assignments like rand() { local max=$((32768 / $2 * $2)) while (( ($1=$RANDOM) >= max )); do :; done : $(( $1 %=$2 )) } or if its a non integer you can set it like rand() { local max=$((32768 / $2 * $2)) local val while (( (val=$RANDOM) >= max )); do :; done printf "$1" "%s" "$(( val % $2 ))" }
|
[Prev in Thread] | Current Thread | [Next in Thread] |