Improve 2012/konno/try.sh
Now randomly selects 10 numbers (in range $((RANDOM % 101))). Also allows one to pass in numbers (or if they wish to they can pass in non-numbers) to pass to the program. The script has new fun numbers. Removed that the valid range is from 0 - 255 as numbers bigger than 255 not only work but some show some fun output (a number of which are used in the script now).
This commit is contained in:
1 parent
69ee0b8de6
commit
bf98cc9052
2 files changed
+45
-17
No files matched your search
+39
-15
@@ -15,47 +15,71 @@ make CC="$CC" all >/dev/null || exit 1
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
echo "$ ./konno 30" 1>&2
|
||||
# let user specify args to run on program too
|
||||
while [[ "$#" -ge 1 ]]; do
|
||||
read -r -n 1 -p "Press any key to run: ./konno $1: "
|
||||
echo 1>&2
|
||||
./konno "$1"
|
||||
echo 1>&2
|
||||
shift 1
|
||||
done
|
||||
|
||||
# use ten random values (in range $((RANDOM % 101)))
|
||||
i=0
|
||||
# we do it this way to prevent the annoying shellcheck warning that 'i' appears
|
||||
# to be unused (as it would be if 'for i in {0..9}; do .. done').
|
||||
while [[ "$i" -lt 10 ]]; do
|
||||
NUM="$((RANDOM % 101))"
|
||||
read -r -n 1 -p "Press any key to run: ./konno $NUM: "
|
||||
echo 1>&2
|
||||
./konno "$NUM"
|
||||
echo 1>&2
|
||||
((i++))
|
||||
done
|
||||
|
||||
|
||||
# finally use some preselected values
|
||||
read -r -n 1 -p "Press any key to run: ./konno 30: "
|
||||
echo 1>&2
|
||||
./konno 30
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
read -r -n 1 -p "Press any key to run: ./konno 90: "
|
||||
echo 1>&2
|
||||
echo "$ ./konno 90" 1>&2
|
||||
./konno 90
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
read -r -n 1 -p "Press any key to run: ./konno 102: "
|
||||
echo 1>&2
|
||||
echo "$ ./konno 102" 1>&2
|
||||
./konno 102
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
read -r -n 1 -p "Press any key to run: ./konno 109: "
|
||||
echo 1>&2
|
||||
echo "$ ./konno 109" 1>&2
|
||||
./konno 109
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
read -r -n 1 -p "Press any key to run: ./konno 165: "
|
||||
echo 1>&2
|
||||
echo "$ ./konno 165" 1>&2
|
||||
./konno 165
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
read -r -n 1 -p "Press any key to run: ./konno 42: "
|
||||
echo 1>&2
|
||||
echo "$ ./konno 42" 1>&2
|
||||
./konno 42
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
read -r -n 1 -p "Press any key to run: ./konno 37: "
|
||||
echo 1>&2
|
||||
echo "$ ./konno 37" 1>&2
|
||||
./konno 37
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
read -r -n 1 -p "Press any key to run: ./konno 255: "
|
||||
echo 1>&2
|
||||
echo "$ ./konno 255" 1>&2
|
||||
./konno 255
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./konno 10000: "
|
||||
echo 1>&2
|
||||
./konno 10000
|
||||
echo 1>&2
|
||||
Reference in new issue
Block a user