#-- # Author:: Tyler Rick # Copyright:: Copyright (c) 2007 QualitySmith, Inc. # License:: Ruby License # Submit to Facets?:: Yes #++ require 'rubygems' require 'escape' # http://www.a-k-r.org/escape/ require 'extensions/symbol' unless Symbol.method_defined?(:to_proc) require 'facets/core/kernel/require_local' class String def shell_escape Escape.shell_command([self]) end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TheTest < Test::Unit::TestCase def assert_that_echo_gives_back_what_we_put_in(input) input = %q{!&'"`$0 |()<>} output = `echo -n #{input.shell_escape}` assert_equal input, output end def test_1 assert_that_echo_gives_back_what_we_put_in( %q{!&'"`$0 |()<>} ) end def test_2 assert_that_echo_gives_back_what_we_put_in( %q{'an arg that's got "quotes"} ) end end =end