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

Add way to query absolute path for current directory? #2794

Closed
fingolfin opened this issue Sep 8, 2018 · 2 comments · Fixed by #5585
Closed

Add way to query absolute path for current directory? #2794

fingolfin opened this issue Sep 8, 2018 · 2 comments · Fixed by #5585
Labels
kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements
Milestone

Comments

@fingolfin
Copy link
Member

For a script, I wanted to temporarily change the current working directory and later restore it. I naively thought I could use record the value of DirectoryCurrent(), then call ChangeDirectoryCurrent (from the IO package), and later restore to the stored path.

But that doesn't work, because DirectoryCurrent()always returns the same thing: dir("./").

I found no way to get the CWD, in particular no calls to getwd or getcwd in GAP or IO (well, GAP now has one in the internal function find_yourself, but that's not helpful).

There is GAPInfo.SystemEnvironment.PWD, but that isn't updated if ChangeDirectoryCurrent is called, so it's only helpful if no code before mine changed the CWD.

For now, I'll resort to using Process to executed pwd in a shell. But I really think we should add something here that does this in a more straightforward way.

BTW, I also noticed that @ChrisJefferson back in 2015 changed io to only defined ChangeDirectoryCurrent if it wasn't defined already -- my guess is in order to add this function to the GAP library. But that hasn't happened, has it?

@fingolfin
Copy link
Member Author

I just released IO 4.5.4 which adds IO_getcwd. But I still think GAP should have something like this builtin.

@fingolfin fingolfin added the kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements label Mar 21, 2019
@fingolfin fingolfin changed the title No way to get absolute path for current directory? Add way to query absolute path for current directory? Mar 26, 2019
@dimpase
Copy link
Member

dimpase commented Nov 22, 2022

By the way, how does one extract "foo" from these dir("foo") created by DirectoryCurrent() and many other similar functions, e.g. DirectoriesPackagePrograms(...) ?

It's not documented, or at least is beyond my ability to find this in GAP docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements
Projects
None yet
2 participants