File tree Expand file tree Collapse file tree 3 files changed +7
-24
lines changed
Expand file tree Collapse file tree 3 files changed +7
-24
lines changed Original file line number Diff line number Diff line change @@ -165,19 +165,14 @@ get_user_owner() {
165165# Random password generator
166166generate_password () {
167167 matrix=$1
168- lenght =$2
168+ length =$2
169169 if [ -z " $matrix " ]; then
170- matrix=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
170+ matrix=[:alnum:]
171171 fi
172- if [ -z " $lenght " ]; then
173- lenght =10
172+ if [ -z " $length " ]; then
173+ length =10
174174 fi
175- i=1
176- while [ $i -le $lenght ]; do
177- pass=" $pass ${matrix: $(($RANDOM % ${# matrix} )): 1} "
178- (( i++ ))
179- done
180- echo " $pass "
175+ cat /dev/urandom | tr -dc $matrix | head -c$length
181176}
182177
183178# Package existence check
Original file line number Diff line number Diff line change @@ -6,13 +6,7 @@ load 'test_helper/bats-file/load'
66
77
88function random() {
9- MATRIX=' 0123456789'
10- LENGTH=$1
11- while [ ${n:= 1} -le $LENGTH ]; do
12- rand=" $rand ${MATRIX: $(($RANDOM % ${# MATRIX} )): 1} "
13- let n+=1
14- done
15- echo " $rand "
9+ cat /dev/urandom | tr -dc [:digit:] | head -c$1
1610}
1711
1812function setup() {
Original file line number Diff line number Diff line change @@ -7,13 +7,7 @@ V_TEST="$HESTIA/test"
77
88# Define functions
99random () {
10- MATRIX=' 0123456789'
11- LENGTH=$1
12- while [ ${n:= 1} -le $LENGTH ]; do
13- rand=" $rand ${MATRIX: $(($RANDOM % ${# MATRIX} )): 1} "
14- let n+=1
15- done
16- echo " $rand "
10+ cat /dev/urandom | tr -dc [:digit:] | head -c$1
1711}
1812
1913echo_result () {
You can’t perform that action at this time.
0 commit comments