the $( COMMAND )$? trick is a very bad one. Please don't advertise it, it basically NEVER works as you intend it to.
$( COMMAND )$?
Not sure what your experience is, but mine is that it works pretty much exactly as one would reasonably expect. It's functionally equivalent to executing something like:
if [[ $? ]]
But without any shell-linters bitching about using an inefficient execution-form.
That said, you need to be familiar with what the subshelled-command's likely outputs are going to be. Which is to say:
Some comments have been hidden by the post's author - find out more
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.