Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

• Add `Rush::quote`, a method to quote a path.

  The quoted path can safely be used inside shellout (like backticks).
  Quotation function adapted from TextMate’s `e_sh` function (lib/escape.rb).
• Add `Rush::Entry.quoted_path`, which returns an entry’s quoted `full_path`.
  • Loading branch information...
commit 130084d61657fe64b10fe9b22464a80c2b61f417 1 parent 88657bb
@mkhl mkhl authored committed
Showing with 9 additions and 0 deletions.
  1. +5 −0 lib/rush.rb
  2. +4 −0 lib/rush/entry.rb
View
5 lib/rush.rb
@@ -54,6 +54,11 @@ def self.my_process
def self.box
@@box = Rush::Box.new
end
+
+ # Quote a path for use in backticks, say.
+ def self.quote(path)
+ path.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
+ end
end
module Rush::Connection; end
View
4 lib/rush/entry.rb
@@ -50,6 +50,10 @@ def full_path
"#{@path}/#{@name}"
end
+ def quoted_path
+ Rush.quote(full_path)
+ end
+
# Return true if the entry currently exists on the filesystem of the box.
def exists?
stat
Please sign in to comment.
Something went wrong with that request. Please try again.