-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Feature Request: box::get_script_path()
#239
Comments
box::set_script_path()
Lops Off Path Componentget_script_path()
get_script_path()
box::get_script_path()
To do
Out of curiosity, what’s your use-case for |
Actually the documentation is correct, and this is a bug. |
Hello again, Konrad! Thanks for your thoughtful responses!
Well, I'll tell you my tale of woe. The use case is a special API for my colleagues, which wraps much of Specifically, I have developed a custom function called
The function works by calling I have striven to remain highly aware of parsing conventions, for the argument(s) to However, for modules located at the very root ( Now I have taken precautions against At the moment, the only way to access the script path is to set it anew, and then capture the (invisible) return value (the And that, my friend, is my sorry tale of woe. |
😆 … ahem. Sorry. It just seems to me that you could avoid a lot of problems, and make your own life easier, by just not storing modules at the very root of the filesystem hierarchy (in your case, At any rate I’ll fix the currently broken return value of This will break your current code I’m afraid (which expects the last part of the path to be missing), I hope that won’t cause too much of an inconvenience. |
* Rename `script_path` to `module_path` This leaves the name `script_path` free to be used in the public API as a getter analog to `set_script_path`. * Fix `set_script_path` return value, add getter
Hello Konrad! As always, I am impressed by your responsiveness and pride in your work! Regarding your last update:
You are indeed correct. However, since my colleagues are not necessarily experienced with
Much appreciated! This will be a big help to me, and it should also be a major convenience for others. :)
No worries! In constructing my API, I have striven to be as modular as possible (in the spirit of Thanks again! — Greg |
* Rename `script_path` to `module_path` This leaves the name `script_path` free to be used in the public API as a getter analog to `set_script_path`. * Fix `set_script_path` return value, add getter
Issue
Per the documentation for
box::set_script_path()
, we can capture the previous script path when setting it anew:However, when I try to capture each previous path, I get the following output
where the terminal filename (
Test.R
) or directory name (Public Documents
) is "lopped off" each captured path.Notably, this behavior ends at the root drive, which is not lopped off:
Thus, valuable information can be lost whenever we change a path.
Acknowledgement
After perusing the source code, I see that this behavior is due to the intentional use of
dirname()
, and it is baked into thescript_path_env$value
as soon as the script path is set. This feature is doubtless tied to important functionality, so I obviously wouldn't request a massive rewrite.However, the manual strongly indicates the filepath itself, rather than the path to the parent directory. A slight revision to the manual would greatly improve clarity.
Request
This issue arose while I was hacking together an augmentation for
box
. I always like to have aget*()
for everyset*()
, so I put together aget_script_path()
function in a utility module:However, this approach might prove unstable. Would it be possible to provide a
box::get_script_path()
function, which simply returns thecharacter
string currently being used as the script path?Thanks, as always! — Greg
The text was updated successfully, but these errors were encountered: