yet-another-bench-script
yet-another-bench-script copied to clipboard
Add check for commands like curl, wget etc. and fix some linter warnings
Description
Just added a check for commands that are in the system, list them and show which do we have and not. If we don't have curl
or wget
- then don't run this script at all (maybe we should anyway?)
Also fixed some warnings that https://www.shellcheck.net/ reports along the way.
Linter issues
Fixed some of them from https://www.shellcheck.net/ output:
-
SC2015 (info): Lines 119, 120, 123, 126, 254 - Note that
A && B || C
is notif-then-else
.C
may run whenA
is true. -
SC2236 (style): Lines 129, 138, 168, 169, 170, 171, 172, 173, 174, 175, 176, 187, 189, 255, 261, 326, 371, 374, 376, 377, 627, 631, 659, 690, 705, 715, 791, 833, 844, 852, 887, 900, 902, 904, 927, 991, 1004, 1007, 1010, 1017 - Use
-n
instead of! -z
. -
SC2002 (style): Lines 271, 274 - Useless
cat
. Consider usingcmd < file
orcmd file
instead. - SC2155 (warning): Lines 328, 329, 330, 332, 339, 340, 341, 342, 343, 344, 345 - Declare and assign separately to avoid masking return values.
- SC2329 (info): Line 408 - The function is never invoked. Check usage (or ignored if invoked indirectly).
-
SC2004 (style): Lines 556, 754, 757, 782, 785, 1016 -
$/${}
is unnecessary on arithmetic variables. - SC2068 (error): Line 588 - Double quote array expansions to avoid re-splitting elements.
- SC1143 (error): Line 876 - This backslash is part of a comment and does not continue the line.
- SC2183 (warning): Lines 685, 699 - This format string has more variables than are passed as arguments.
- SC2046 (warning): Lines 667, 673, 967 - Quote this to prevent word splitting.
-
SC2116 (style): Lines 797, 827, 1016 - Useless
echo
. Instead ofcmd $(echo foo)
, just usecmd foo
. -
SC2003 (style): Lines 691, 713 -
expr
is antiquated. Consider rewriting this using$((..))
,${}
or[[ ]]
.
Other fixes
- Added
overlay
type intoTOTAL_DISK_RAW
variable to calculate available space if we are running inside of Docker.
Examples
Example output of x64 Alpine Edge
from Dockerhub:
Checking available commands
---------------------------------
locale : ❌ not installed
uname : ✔ installed
getconf : ✔ installed
awk : ✔ installed
sed : ✔ installed
grep : ✔ installed
cut : ✔ installed
shuf : ✔ installed
timeout : ✔ installed
date : ✔ installed
trap : ✔ installed
df : ✔ installed
free : ✔ installed
systemd-detect-virt : ❌ not installed
wget : ✔ installed
x64 Ubuntu Focal
from Dockerhub:
Checking available commands
---------------------------------
locale : ✔ installed
uname : ✔ installed
getconf : ✔ installed
awk : ✔ installed
sed : ✔ installed
grep : ✔ installed
cut : ✔ installed
shuf : ✔ installed
timeout : ✔ installed
date : ✔ installed
trap : ✔ installed
df : ✔ installed
free : ✔ installed
systemd-detect-virt : ❌ not installed
curl/wget : ❌ not installed
Error: Neither 'curl' nor 'wget' command found. Please install one of those to continue.
x64 Photon 5.0
:
Checking available commands
---------------------------------
locale : ✔ installed
uname : ✔ installed
getconf : ✔ installed
sed : ✔ installed
grep : ✔ installed
cut : ✔ installed
shuf : ❌ not installed
timeout : ✔ installed
date : ✔ installed
trap : ✔ installed
df : ✔ installed
free : ✔ installed
systemd-detect-virt : ❌ not installed
curl : ✔ installed
awk : ❌ not installed
Error: 'awk' command found. Please install one of those to continue, script heavily relies on it.
x64 Clearlinux
latest, Mageia 9
:
Checking available commands
---------------------------------
locale : ✔ installed
uname : ✔ installed
getconf : ✔ installed
sed : ✔ installed
grep : ✔ installed
cut : ✔ installed
shuf : ✔ installed
timeout : ✔ installed
date : ✔ installed
trap : ✔ installed
df : ✔ installed
free : ✔ installed
systemd-detect-virt : ✔ installed
curl : ✔ installed
awk : ✔ installed