fix(fish): ROS2 still initializes even if not in distrobox
This commit is contained in:
@@ -1,18 +1,21 @@
|
|||||||
# ROS2 development environment (requires distrobox)
|
# ROS2 development environment (requires distrobox)
|
||||||
# Environment: {{ENV_NAME}}
|
# Environment: {{ENV_NAME}}
|
||||||
|
|
||||||
|
# First check if running inside distrobox
|
||||||
|
if not test -f /run/.containerenv; and test -z "$CONTAINER_ID"
|
||||||
|
echo (set_color red)"This ROS2 environment should only be run inside a distrobox container"(set_color normal)
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
# Check if a previous initialization has occurred
|
# Check if a previous initialization has occurred
|
||||||
if test -n "$__ENV_INITIALIZED"
|
if test -n "$__ENV_INITIALIZED"
|
||||||
echo (set_color yellow)"Environment already initialized"(set_color normal)
|
echo (set_color yellow)"Environment already initialized"(set_color normal)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Mark as initialized
|
# Mark as initialized (only after distrobox check passes)
|
||||||
set -gx __ENV_INITIALIZED "1"
|
set -gx __ENV_INITIALIZED "1"
|
||||||
set -gx CURRENT_ENV "{{ENV_NAME}}"
|
set -gx CURRENT_ENV "{{ENV_NAME}}"
|
||||||
|
|
||||||
# Check if running inside distrobox
|
|
||||||
if test -f /run/.containerenv; or test -n "$CONTAINER_ID"
|
|
||||||
# Source ROS2 setup files using bass
|
# Source ROS2 setup files using bass
|
||||||
if type -q bass
|
if type -q bass
|
||||||
bass source /opt/ros/jazzy/setup.bash
|
bass source /opt/ros/jazzy/setup.bash
|
||||||
@@ -56,10 +59,6 @@ if test -f /run/.containerenv; or test -n "$CONTAINER_ID"
|
|||||||
alias ctr="colcon test-result"
|
alias ctr="colcon test-result"
|
||||||
|
|
||||||
echo (set_color green)"Activated ROS2 environment: {{ENV_NAME}}"(set_color normal)
|
echo (set_color green)"Activated ROS2 environment: {{ENV_NAME}}"(set_color normal)
|
||||||
else
|
|
||||||
echo (set_color red)"This ROS2 environment should only be run inside a distrobox container"(set_color normal)
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# Custom deactivation function
|
# Custom deactivation function
|
||||||
function __env_custom_deactivate
|
function __env_custom_deactivate
|
||||||
|
|||||||
Reference in New Issue
Block a user