StoglRobotics / ros_team_workspace

RosTeamWorkspace is a framework for boosting collaboration in teams when developing software for robots using Robot Operating System (ROS1 and ROS2).
https://rtw.stoglrobotics.de
Apache License 2.0
79 stars 17 forks source link

[setup-auto-sourcing] check for commented sourcing in ~/.bashrc #205

Open YaraShahin opened 2 months ago

YaraShahin commented 2 months ago

Hello

This is not an issue, but it could be an imporvement. I setup ros_team_workspace with autosourcing a while ago, but I commented out the following lines from my ~/.bashrc when I stopped using it:

if [ -f ~/.ros_team_ws_rc ]; then
    . ~/.ros_team_ws_rc
fi

When I wanted to use it again by running the command setup-auto-sourcing, I expected it to add the lines again or remove # but it didn't modify my ~/.bashrc at all. This is probably because of this condition in setup_auto_sourcing.bash:

if ! ( grep -q '\..*\.ros_team_ws_rc' $bashrc_location || grep -q 'source.*\.ros_team_ws_rc' $bashrc_location ); then
    echo "" >> $bashrc_location
    echo "# automatically source RosTeamWorkspace if the .ros_team_ws file is present in your home folder." >> $bashrc_location
    echo "if [ -f ~/.ros_team_ws_rc ]; then" >> $bashrc_location
    echo "    . ~/.ros_team_ws_rc" >> $bashrc_location
    echo "fi" >> $bashrc_location
fi

This checks that . ~/.ros_team_ws_rc exists without checking if it was commented out (if there's a # at the start of the line.

Steps to reproduce:

  1. Clone repo (master) & run source setup.bash
  2. run setup-auto-sourcing
  3. Go to ~/.bashrc & comment out the lines:
    if [ -f ~/.ros_team_ws_rc ]; then
      . ~/.ros_team_ws_rc
    fi
  4. run setup-auto-sourcing again.
  5. You'll notice that the setup.bash isn't sourced because the lines in ~/.bashrc aren't included back in.