yet-another-bench-script icon indicating copy to clipboard operation
yet-another-bench-script copied to clipboard

Add check for commands like curl, wget etc. and fix some linter warnings

Open hugmouse opened this issue 8 months ago • 4 comments

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:

  1. SC2015 (info): Lines 119, 120, 123, 126, 254 - Note that A && B || C is not if-then-else. C may run when A is true.
  2. 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.
  3. SC2002 (style): Lines 271, 274 - Useless cat. Consider using cmd < file or cmd file instead.
  4. SC2155 (warning): Lines 328, 329, 330, 332, 339, 340, 341, 342, 343, 344, 345 - Declare and assign separately to avoid masking return values.
  5. SC2329 (info): Line 408 - The function is never invoked. Check usage (or ignored if invoked indirectly).
  6. SC2004 (style): Lines 556, 754, 757, 782, 785, 1016 - $/${} is unnecessary on arithmetic variables.
  7. SC2068 (error): Line 588 - Double quote array expansions to avoid re-splitting elements.
  8. SC1143 (error): Line 876 - This backslash is part of a comment and does not continue the line.
  9. SC2183 (warning): Lines 685, 699 - This format string has more variables than are passed as arguments.
  10. SC2046 (warning): Lines 667, 673, 967 - Quote this to prevent word splitting.
  11. SC2116 (style): Lines 797, 827, 1016 - Useless echo. Instead of cmd $(echo foo), just use cmd foo.
  12. SC2003 (style): Lines 691, 713 - expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].

Other fixes

  • Added overlay type into TOTAL_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

hugmouse avatar Jun 19 '24 16:06 hugmouse