While learning colcon for ROS 2 (as migrating from ROS 1).
I expected to colcon_cd to work like the ROS 1 roscd which allows for the following:
you:~/some_path$ roscd SOME_PACKAGE
you:/path/to/SOME_PACKAGE$ cd - # Return to previous PWD
you:~/some_path$
This was allowed since roscd only uses cd just before returning, allowing to use this default mechanism of cd.
However, when using colcon_cd the result is as follows:
you:~/some_path$ colcon_cd SOME_PACKAGE
you:/path/to/SOME_PACKAGE$ cd -
you:/path/to$ # Not where I expected to end up
As a result of some digging in the source, this is the result of cd-ing multiple times.
Looking at the cd documentation, this could possibly be changed by setting the OLDPWD environment variable, which is used to store the old path.
EDIT: I can make a PR for this if this change is desired.