From 080e74951f679c9376b67199df1bebb498398e5c Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 20 Jul 2009 02:47:08 +0200 Subject: added Array#sh, cleaned up code/extensions/basic.rb --- code/extensions/basic.rb | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'code') diff --git a/code/extensions/basic.rb b/code/extensions/basic.rb index c07402d7..0dbd8a96 100644 --- a/code/extensions/basic.rb +++ b/code/extensions/basic.rb @@ -20,6 +20,15 @@ class Array self[n .. -1] end alias car first + def sh + map do |x| + if x.respond_to? :path + x.path.to_s + else + x.to_s + end.sh + end.join(" ") + end end class String @@ -65,20 +74,6 @@ class String Directory::Entry::MIMETYPES[self] || 'unknown' end - def sh - res = self.dup - res.gsub!('\\\\', "\000") - res.gsub!(' ', '\\ ') - res.gsub!('(', '\\(') - res.gsub!('&', '\\\&') - res.gsub!(')', '\\)') - res.gsub!('*', '\\*') - res.gsub!('\'', "\\\\'") - res.gsub!('"', '\\"') - res.gsub!("\000", '\\\\') - return res - end - ## encodes a string for the shell. ## peter's song.mp3 -> 'peter'\''s song.mp3' ## @@ -90,6 +85,7 @@ class String "#{ gsub("'", "'\\\\''") }" end alias ~ bash_escape + alias sh bash_escape end class Numeric -- cgit 1.4.1-2-gfad0 vc/README.md?h=v0.4.0&id=fb328631e55830f3a2cab79bf18115324910c93c'>tree commit diff stats
path: root/svc/README.md
blob: c0ede0e0341f4dcfc8b62d36cbfe3c4d84edcf00 (plain) (blame)
1
2
3
4
5
6
7
8