Skip to content

Commit

Permalink
fix ShellCheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mmitch committed Dec 17, 2023
1 parent 80b4cda commit 8db8c92
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ copyright

bash-n - bash library for connect-n game clients

Copyright (C) 2019, 2020 Christian Garbs <mitch@cgarbs.de>
Copyright (C) 2019, 2020, 2023 Christian Garbs <mitch@cgarbs.de>
Licensed under GNU GPL v3 or later.

bash-n is free software: you can redistribute it and/or modify
Expand Down
12 changes: 6 additions & 6 deletions bash-n-simplebot
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# To connect to a SERVER on PORT via UDP, run this script like this:
# $ socat udp:SERVER:PORT exec:bash-n-simplebot
#
# Copyright (C) 2019 Christian Garbs <mitch@cgarbs.de>
# Copyright (C) 2019, 2023 Christian Garbs <mitch@cgarbs.de>
# Licensed under GNU GPL v3 or later.
#
# This file is part of bash-n.
Expand All @@ -35,25 +35,25 @@ calculate_move()
{
local column
while true; do
column=$(( $RANDOM % 7 )) # this will be biased!
if [ ${field[$column]} -lt 6 ]; then
column=$(( RANDOM % 7 )) # this will be biased!
if [ "${field[column]}" -lt 6 ]; then
return $column
fi
done
}

record_move()
{
local who=$1 column=$2
field[$column]=$((${field[$column]} + 1))
local column=$2 # who=$1 (unused)
field[column]=$((${field[$column]} + 1))
echo "${field[*]}"
}

game_start()
{
local column
for column in 0 1 2 3 4 5 6; do
field[$column]=0
field[column]=0
done
}

Expand Down
14 changes: 7 additions & 7 deletions bash-n-towerbot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# To connect to a SERVER on PORT via UDP, run this script like this:
# $ socat udp:SERVER:PORT exec:bash-n-simplebot
#
# Copyright (C) 2019 Christian Garbs <mitch@cgarbs.de>
# Copyright (C) 2019, 2023 Christian Garbs <mitch@cgarbs.de>
# Licensed under GNU GPL v3 or later.
#
# This file is part of bash-n.
Expand All @@ -35,11 +35,11 @@ source bash-n-client
calculate_move()
{
if column_is_available; then
return $column
return "$column"
fi

while true; do
column=$(( $RANDOM % 7 )) # this will be biased!
column=$(( RANDOM % 7 )) # this will be biased!
if column_is_available; then
return $column
fi
Expand All @@ -48,20 +48,20 @@ calculate_move()

column_is_available()
{
[ ${field[$column]} -lt 6 ]
[ "${field[column]}" -lt 6 ]
}

record_move()
{
local who=$1 column=$2
field[$column]=$((${field[$column]} + 1))
local column=$2 # who=$1 (unused)
field[column]=$((${field[$column]} + 1))
echo "${field[*]}"
}

game_start()
{
for column in 0 1 2 3 4 5 6; do
field[$column]=0
field[column]=0
done
column=3
}
Expand Down

0 comments on commit 8db8c92

Please sign in to comment.