summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2022-10-21 14:56:31 +0900
committernagachika <nagachika@ruby-lang.org>2022-10-21 14:56:31 +0900
commit3f3a5ec04222fd03945e3e6ef2e79ff7d07ce677 (patch)
treed0ce5e225f69a35039b9d2ed91524e1d01b92f37
parent5822577a9b5e41b6c9187bce630b092d1cd591dc (diff)
merge revision(s) 6c1d7dab52b9bd26cbb624634b4acb86ba37aa7f:
Fix conversion from absolute path to relative path --- tool/ln_sr.rb | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
-rw-r--r--tool/ln_sr.rb25
-rw-r--r--version.h2
2 files changed, 16 insertions, 11 deletions
diff --git a/tool/ln_sr.rb b/tool/ln_sr.rb
index 307daa3202..6ab412edde 100644
--- a/tool/ln_sr.rb
+++ b/tool/ln_sr.rb
@@ -30,23 +30,28 @@ unless respond_to?(:ln_sr)
def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)
options = "#{force ? 'f' : ''}#{target_directory ? '' : 'T'}"
dest = File.path(dest)
- srcs = Array.try_convert(src) || [src]
+ srcs = Array(src)
link = proc do |s, target_dir_p = true|
s = File.path(s)
+ if target_dir_p
+ d = File.join(destdirs = dest, File.basename(s))
+ else
+ destdirs = File.dirname(d = dest)
+ end
+ destdirs = fu_split_path(File.realpath(destdirs))
if fu_starting_path?(s)
srcdirs = fu_split_path((File.realdirpath(s) rescue File.expand_path(s)))
+ base = fu_relative_components_from(srcdirs, destdirs)
+ s = File.join(*base)
else
srcdirs = fu_clean_components(*fu_split_path(s))
+ base = fu_relative_components_from(fu_split_path(Dir.pwd), destdirs)
+ while srcdirs.first&. == ".." and base.last&.!=("..") and !fu_starting_path?(base.last)
+ srcdirs.shift
+ base.pop
+ end
+ s = File.join(*base, *srcdirs)
end
- destdirs = fu_split_path(File.realdirpath(dest))
- destdirs.pop unless target_dir_p
- base = fu_relative_components_from(fu_split_path(Dir.pwd), destdirs)
- while srcdirs.first&. == ".." and base.last and !fu_starting_path?(base.last)
- srcdirs.shift
- base.pop
- end
- s = File.join(*base, *srcdirs)
- d = target_dir_p ? File.join(dest, File.basename(s)) : dest
fu_output_message "ln -s#{options} #{s} #{d}" if verbose
next if noop
remove_file d, true if force
diff --git a/version.h b/version.h
index dceb8f6f7d..e54a2887bd 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 3
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 137
+#define RUBY_PATCHLEVEL 138
#define RUBY_RELEASE_YEAR 2022
#define RUBY_RELEASE_MONTH 10