-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
POSIX-compliant implementation of relative_path.sh #16838
Conversation
This is an alternative implementation of relative_path.sh, authored by @simonair on http://stackoverflow.com/a/14914070 Known limitations: it doesn't clean multiple slashes and doesn't resolve symlinks. Let's see if it passes Travis CI.
|
||
echo $result | ||
#!/bin/sh | ||
# This file is a part of StackOverflow. License is CC-BY-SA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"based on code from" - and add this file to the exception list in contrib/add_license_to_files.jl
there's also a comment on SO that "Doesn't work when the first path ends in / I'm afraid." not sure what to make of that or how general we need this to be. |
I did a quick test and it appears to work. Maybe that comment refers to another implementation, there are 3 of them in simon's answer. About multiple slashes, if it's really a concern, we can pipe the output of relpath through sed s#//*#/#g |
there were failure cases linked above that we want to be sure we're not reintroducing |
If we decide this version is okay it would also be worth asking @simonair if he would be willing to relicense his code snippet as MIT. |
I'm honored to see my little code snippet be of use. I would be happy to license it under the MIT license – what do I need to do? |
Saying so is all you need to do. Thanks! |
Yep, thanks much! We can then remove the license special-casing for that file, and give it the standard same MIT banner we give everything else. More convenient to have fewer exceptions. |
With licensing solved, we just have to wait for @Keno to give the green-light and it can be merged. |
Two simple questions.
Can someone answer these questions? |
Did you check that it correctly handles the two corner cases we had issues for above, i.e. |
Is this what you ask?
|
Yes, those were the two failure cases in the old script that we had to fix. LGTM then. |
Do you think it's necessary to deal with multiple slashes? Or can it be merged already? |
Doesn't look like the current script does so. Everywhere we call it should be getting passed off to things that will deal with multiple slashes as expected. |
This is an alternative implementation of relative_path.sh, authored by @simonair on http://stackoverflow.com/a/14914070
Known limitations: it doesn't clean multiple slashes and doesn't resolve symlinks.
Let's see if it passes Travis CI.