Enhance script robustness, simplicity, portability, and performance.
The leading goal is to make the script more robust and maintainable, while enhancing its simplicity, portability and performance. Commits have been combined into a cohesive whole for greater clarity. TigerStyle was followed when possible.
There are extensive changes, including but not limited to the following:
- Fix all
shellcheckwarnings, errors and issues (45warnings,53info). - Fix potentially removing root directory on empty values.
- Add better checks, constraints, redirections and exit codes.
- Add logic to handle Shodan membership warning instead of returning errors.
- Use
set -Cefuto enforce error exits, prevent var misuse and ensure safer file redirections.1 - Add fallbacks and support environmental variables.
- Use unified curl connections...
- Upgrade most
curlinsecure connections to not use-k.
- Reduce codebase by around a half of its original size:
≈ 51.72% code reduction
(
36663->17754bytes,1033->946lines). - Remove redundancy with functions, loops, and variables.
- Use composability over hardcoded and heavily coupled code.
- Use lowercase for variable names, as it's idiomatic to reserve uppercase for environmental variables.
- Removed comments in favor of concise code and descriptive naming.
- Enhance script portability to run with other POSIX shells, supporting:
bash,dash,ksh93,mksh,oksh,osh,posh,yash,zsh. - Use
/bin/shwith standard idioms, following POSIX spec closely. - Support and test different platforms
Linux,macOS,FreeBSD. - Migrate
grep -PPCRE regex to POSIX-compatible regular expressions.
- Reduce runtime overhead performance ≈
55 ms, from205.9 msto150.6 ms.2 - Reduce the number of syscalls, from
5279to4530total.3 - Use the system default nameserver instead of
8.8.8.8.
- Add new logo.
- Add
XDG_DATA_HOMEsupport loading fallbacks (e.g.API.conf,XDG_DATA_HOME/uncloakCDN/API.conf,$HOME/.local/share/uncloakCDN/API.conf). - Display colors only in terminal outputs, not in pipes or file writes.
- Check dependencies availability in current environment.
- Add
-nto disable terminal colors. - Deprecated
-iin favor of-aand-hmsc - Add manpage using
mdoc
The new version should have equivalent functionality. Further testing is recommended.
Footnotes
-
See: ExplainShell: set -Cefu ↩
-
cfr. Benchmarked with
hyperfineon-d 127.0.0.1. ↩ -
cfr. Counted with
dtraceunder Kali Linux 2024.1, with-c. ↩