From 8c719cde323fc19957048bedfcdc683e95b7c5f7 Mon Sep 17 00:00:00 2001 From: Nathan Stratton Treadway Date: Mon, 27 Aug 2012 14:15:34 -0400 Subject: [PATCH] ignore trailing slash on directory argument When a directory is specified on the command line, ignore any trailing slashes on that path name. (Before this fix, including a trailing slash on a directory name would prevent that path from being stripped off the front of the output filenames as it should have been.) --- rcs-fast-export.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rcs-fast-export.rb b/rcs-fast-export.rb index c8e7ff8..3cfa5a2 100755 --- a/rcs-fast-export.rb +++ b/rcs-fast-export.rb @@ -817,12 +817,17 @@ file_list.each do |arg| end rcs << RCS.parse(filename, rcsfile) when 'directory' - pattern = File.join(arg, '**', '*' + SFX) + argdirname = arg.chomp(File::SEPARATOR) + pattern = File.join(argdirname, '**', '*' + SFX) Dir.glob(pattern).each do |rcsfile| filename = File.basename(rcsfile, SFX) path = File.dirname(rcsfile) path.sub!(/\/?RCS$/, '') # strip final /RCS if present - path.sub!(/^#{Regexp.escape arg}\/?/, '') # strip initial dirname + # strip off the portion of the path sepecified + # on the command line from the front of the path + # (or delete the path completely if it is the same + # as the specified directory) + path.sub!(/^#{Regexp.escape argdirname}(#{File::SEPARATOR}|$)/, '') filename = File.join(path, filename) unless path.empty? begin rcs << RCS.parse(filename, rcsfile) -- 2.32.0.93.g670b81a890