Closed andrew-womeldorf closed 3 years ago
I think it should be as simple as:
if command -v {CONFIG.PODMAN_TOOL} > /dev/null; then
{CONFIG.PODMAN_TOOL} run -it {img_loc} \\\$@
else
...
fi
I don't think we need the subshell. We just want to check the exit code of command -v
right?
Thank you both for the review!
Thank you both for the review!
Can you just remove the command being executed in a subshell as suggested by @Tatskaari? Happy to get this merged afterwards. Thanks!
Can you just remove the command being executed in a subshell as suggested by @Tatskaari? Happy to get this merged afterwards. Thanks!
Yep, done! Thanks!
I'm very open to suggestion for this change! I know this is a common problem with shell scripting, and I'm not sure my solution is "correct".
The problem I'm having is that this conditional always evaluates to true on my machine. The outputted script looks like this:
I don't know if it's "correct" for the evaluation of
$(command -v {CONFIG.PODMAN_TOOL}...)
to occur in the build def, or if that should've been output as$(command -v podman...)
to the shell script. I'm only doing local builds, so it's inconsequential for me.At this point, I can say that I've had success with the conditional correctly evaluating when I remove the brackets. My machine does have
podman
installed, so I expect to evaluate false and run thepodman
command. If I replaceCONFIG.PODMAN_TOOL
with something my machine doesn't have, likedocker
, the conditional correctly evaluates to true.