Been using UNIX since the late 80s; Linux since the mid-90s; virtualization since the early 2000s and spent the past few years working in the cloud space.
Location
Alexandria, VA, USA
Education
B.S. Psychology from Pennsylvania State University
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:
<COMMAND>
if [[ $? ]]
then
…
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:
If the subshelled-command has an output other than just an exit code, you need to suppress it. Some commands have a built-in "quiet" option; for those that don't, you can suppress by redirecting output to /dev/null. Failing to suppress output will tend to cause evaluation-logic to evaluate as a string of <COMMAND_OUTPUT><COMMAND_EXITCODE> rather than an integer of <COMMAND_EXITCODE>.
Similarly, if you care to handle more than a -eq 0 or -ne 0 output, you need to be familiar enough with the given command's possible exit-codes to set up the appropriate handlers you might want/need.
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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:
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:
/dev/null
. Failing to suppress output will tend to cause evaluation-logic to evaluate as a string of<COMMAND_OUTPUT><COMMAND_EXITCODE>
rather than an integer of<COMMAND_EXITCODE>
.-eq 0
or-ne 0
output, you need to be familiar enough with the given command's possible exit-codes to set up the appropriate handlers you might want/need.