Skip to content

Commit 05a0953

Browse files
committed
The function joker() contains a bug where the random station number can be zero, which leads to sed "0q;d" returning nothing and causing errors; you should ensure the random number is at least 1.
1 parent 5cc83db commit 05a0953

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

shelldio.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ joker() {
259259
while IFS='' read -r line || [[ -n "$line" ]]; do
260260
lines=$((lines + 1))
261261
done <"$stations"
262-
station_number=$((RANDOM % lines)) #Διάλεξε τυχαίο σταθμό
262+
station_number=$(( (RANDOM % lines) + 1 )) #Διάλεξε τυχαίο σταθμό (ξεκινάει από 1)
263263
validate_station_lists
264264

265265
while true; do
@@ -319,7 +319,7 @@ joker() {
319319
printf "Απέτυχε ο αυτόματος τερματισμός. \nΠάτα τον συνδυασμό Ctrl+C ή κλείσε το τερματικό \nή τερμάτισε το Shelldio απο τις διεργασίες του συστήματος"
320320
fi
321321
done
322-
station_number=$((RANDOM % lines))
322+
station_number=$(( (RANDOM % lines) + 1 ))
323323
break
324324
fi
325325
done

0 commit comments

Comments
 (0)