There is a problem with the logic here. If which rosversion is false (i.e., the rosversion command isn't found), then it will go ahead and run ROS_VERSION=$(rosversion -ds), which doesn't make any sense since we've already determined that the rosversion command doesn't exist.
It should be something like:
if ! which rosversion > /dev/null || [[ $(rosversion -d) == "<unknown>" ]]; then
echo "No ROS distribution was found. Ensure that /opt/ros/<ROS version>/setup.bash is sourced."
exit 1
fi
This way, only if which rosversion is successful and rosversion -d is successful (e.g., returns melodic), then the if-block will be skipped. This is the only case where the || condition is false.
There is a problem with the logic here. If
which rosversion
is false (i.e., therosversion
command isn't found), then it will go ahead and runROS_VERSION=$(rosversion -ds)
, which doesn't make any sense since we've already determined that therosversion
command doesn't exist.It should be something like:
This way, only if
which rosversion
is successful androsversion -d
is successful (e.g., returnsmelodic
), then the if-block will be skipped. This is the only case where the||
condition is false.