Created
September 9, 2010 20:26
-
-
Save jpr5/572489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The last one is the important lesson -- if *any* component of the path has a | |
# symlink in it (not just the *last* component), Pathname#relative_path_from can | |
# still produce the wrong outcome. | |
# | |
# Admittedly, the example here would actually work because both the real dir and | |
# symlinked dir are both at the same level of path nesting. This example is just | |
# to demonstrate that Pathname#symlink? is an insufficient test in determining | |
# whether or not to call Pathname#realpath. | |
irb(main):001:0> require 'pathname' | |
=> true | |
irb(main):002:0> `mkdir -p dir_tmp/dir_build` | |
=> "" | |
irb(main):003:0> `ln -s dir_tmp sym_tmp` | |
=> "" | |
irb(main):004:0> Dir.chdir("dir_tmp") { `ln -s ../dir_tmp/dir_build sym_build` } | |
=> "" | |
irb(main):005:0> Pathname.new("sym_tmp").symlink? | |
=> true | |
irb(main):006:0> Pathname.new("sym_tmp/sym_build").symlink? | |
=> true | |
irb(main):007:0> Pathname.new("sym_tmp/dir_build").symlink? | |
=> false | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment