current if-block logic is only based on comparing the exit code of the command inside arithmetic block:
output:
if [ "$([ "_${category_48}" != "_server" ]; echo $?)" != 0 ]; then
not only is it not logical for output readability but also expensive in terms of power and time, by using subshells to capture the exit code.
the example above can be simplied to just:
if [ "${category_48}" = "server" ]; then
i know it's most likely made for reliable comparison with nesting and without the need to make the if logic more complicated (by e.g. comparing if condition types)
this also includes stuff like failed:
can be simplified to just
if ! systemctl stop "${server_service_157}" 2>/dev/shm/.mirage_error_catch; then
if failed doesn't include any variable to save status into, but it's rather a bad example since status() still has to store it somehow
my biggest concern is having multiple conditions:
apart from being very long, it contains two subshells inside arithmetic block, which is then tested with is not zero, which makes it harder to debug the source code and understand the logic
current if-block logic is only based on comparing the exit code of the command inside arithmetic block:
output:
not only is it not logical for output readability but also expensive in terms of power and time, by using subshells to capture the exit code.
the example above can be simplied to just:
i know it's most likely made for reliable comparison with nesting and without the need to make the if logic more complicated (by e.g. comparing if condition types)
this also includes stuff like
failed:can be simplified to just
if
faileddoesn't include any variable to save status into, but it's rather a bad example sincestatus()still has to store it somehowmy biggest concern is having multiple conditions:
apart from being very long, it contains two subshells inside arithmetic block, which is then tested with
is not zero, which makes it harder to debug the source code and understand the logic