Permalink
Browse files

Invoking cd directly in the case where there is an exact path match.

  • Loading branch information...
1 parent ad2554f commit 4539e8d5ec3634839e7e291d15eb9fad7fd2d279 harry committed with May 20, 2010
Showing with 4 additions and 9 deletions.
  1. +4 −9 fuzzycd.rb
View
@@ -100,15 +100,10 @@ def matches_for_path(path)
@out = File.open("/tmp/fuzzycd.rb.out", "w")
cd_path = ARGV.join(" ")
-# When no path is provided, just invoke cd directly without arguments.
-if cd_path.nil?
- @out.puts "@passthrough"
- exit
-end
-
-# When the path ends in "/" and for other special-case paths, just let cd handle it directly.
-if [".", "/", "-", ENV["HOME"]].include?(cd_path) || cd_path =~ /\.\.(\/\.\.)*/ ||
- cd_path.rindex("/") == cd_path.size - 1
+# Just invoke cd directly in certain special cases (e.g. when the path is empty, ends in "/" or exactly
+# matches a directory).
+if cd_path.nil? || [".", "/", "-", ENV["HOME"]].include?(cd_path) || cd_path =~ /\.\.(\/\.\.)*/ ||
+ cd_path.rindex("/") == cd_path.size - 1 || File.directory?(cd_path)
@out.puts "@passthrough"
exit
end

0 comments on commit 4539e8d

Please sign in to comment.