ros / catkin

A CMake-based build system that is used to build all packages in ROS.
http://wiki.ros.org/catkin
BSD 3-Clause "New" or "Revised" License
321 stars 280 forks source link

Add native support to fish shell #1168

Closed FelipeGdM closed 2 years ago

FelipeGdM commented 2 years ago

The fish shell is an alternative shell to bash or zsh. It defines itself as a

smart and user-friendly command line shell for Linux, macOS, and the rest of the family.

Fish is already kind of supported by catkin with use of the helper bass, as documented in rosbash ROS wiki page. Specific support for it was already discussed in #921

This PR creates the files setup.fish.in and local_setup.fish.in to provide native setup scripts for fish users. The main benefit from this update is the possibility to use fish scripts as environment hooks in catkin workspaces.

For example, the script rosfish (actual template here) is declared as env hook in the package rosbash

Since bass source setup.bash runs a bash-like setup, this fish env hook is not loaded, so the usual sequence of commands to start a fish workspace is (as shown in rosbash docs)

bass source ~/catkin_ws/devel/setup.bash
source /opt/ros/noetic/share/rosbash/rosfish

With this PR, it becomes a simple

source ~/catkin_ws/devel/setup.fish

With the bonus that not only rosfish is loaded, but also any other fish-specific env hook in the workspace. It is particularly useful to extend packages like ROS Workspace Scripts to fish environments

FelipeGdM commented 2 years ago

@gbiggs I applied the suggested changes and added some fixes for problems that appeared upon further testing

One important addition was the backwards compatibility check to handle .sh scripts registered as fish env hooks. In terms of codebase maintenance, it may be not be a problem to preserve .sh scripts in the fish stack (and thus prevent unnecessary code duplication), bass can handle them as long as they don't declare any bash functions.

In this effort, PR https://github.com/ros/ros/pull/301 was created in order to assert consistency among ROS files