Skip to content

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

@YaraShahin

Description

@YaraShahin

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
  1. run setup-auto-sourcing again.
  2. You'll notice that the setup.bash isn't sourced because the lines in ~/.bashrc aren't included back in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions