Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Going to the previous working directory (cd -) does not behave as expected #27

Open
SuperJappie08 opened this issue Jul 18, 2024 · 4 comments

Comments

@SuperJappie08
Copy link

SuperJappie08 commented Jul 18, 2024

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.

@mjcarroll
Copy link

EDIT: I can make a PR for this if this change is desired.

That would be fantastic.

@SuperJappie08
Copy link
Author

After further inspection, this error only occurs when going to packages not in the current working directory, but on the _colcon_cd_root

@SuperJappie08
Copy link
Author

Currently, I have a draft PR (#28) , which resolves the behavior.

However, the cd history, still gets erased when the package is not found.
Should I also fix that?

@SuperJappie08
Copy link
Author

I also fixed the package not found case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants