I'm trying to create a script where pretty much things got sorted out earlier in it and I'm left with the booleans I need stored in variables. I just need to run them through one last loop and I'm done
This last part I'm talking about is a less readable version of something similar to this:
[↑continues on top↑]
var5="$(some long operation that has different results on different systems )"
var6="$(bc of escaping or slighly different variations on the basic set of )"
var7="$(UNIXy commands preloaded on every system's minimal installation )"
var8="$(e.g: <grep> Um…what else…oh yeah! The output of these is 1 or 0 🤓 )"
varlist='$var1 $var2 ... $var8' # ←I assume 'this' would
# prevent it from being expanded
for ENTRY in $varlist
do
if [ "$ENTRY" ] # ←Already a boolean
then
<perform operation>
else
<log/echo it wasn't needed or something>
fi
done
Would that work? Or rather — is it portable? I'm jumping from macOS*, Fedora, RHEL, Debian and "appliance" FreeBSD (pfSense, OPNsense, …) nonstop. That said, I do mean Fedora, RHEL, Debian, macOS and FreeBSD, no their derivatives/downstreams/whatever so things are very predictable and stable. The most I stray from these systems is Debian on WSL and only because SSH on PowerShell is very glitchy. Am I breaking rules? Do I need to enclose variables in the variables variable (varlist
, I know you just know but to avoid ambiguities) in something else? Maybe escape the $
?
If you have completely different alternatives to suggest, I'm listening. I'm open for anything as long as it still is Bash.
*: pre-Catalina still with Bash by default.