summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/functions/shellquote_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/parser/functions/shellquote_spec.rb')
-rwxr-xr-xspec/unit/parser/functions/shellquote_spec.rb51
1 files changed, 20 insertions, 31 deletions
diff --git a/spec/unit/parser/functions/shellquote_spec.rb b/spec/unit/parser/functions/shellquote_spec.rb
index 283a4de1e..8286be32e 100755
--- a/spec/unit/parser/functions/shellquote_spec.rb
+++ b/spec/unit/parser/functions/shellquote_spec.rb
@@ -19,74 +19,63 @@ describe "the shellquote function" do
end
it "should handle several simple arguments" do
- result = @scope.function_shellquote(
- ['foo', 'bar@example.com', 'localhost:/dev/null', 'xyzzy+-4711,23'])
- result.should(eql(
- 'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
+ result = @scope.function_shellquote( ['foo', 'bar@example.com', 'localhost:/dev/null', 'xyzzy+-4711,23'])
+ result.should(eql( 'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
end
it "should handle array arguments" do
+
result = @scope.function_shellquote(
+
['foo', ['bar@example.com', 'localhost:/dev/null'],
- 'xyzzy+-4711,23'])
+
+ 'xyzzy+-4711,23'])
result.should(eql(
'foo bar@example.com localhost:/dev/null xyzzy+-4711,23'))
end
it "should quote unsafe characters" do
- result = @scope.function_shellquote(
- ['/etc/passwd ', '(ls)', '*', '[?]', "'&'"])
- result.should(eql(
- '"/etc/passwd " "(ls)" "*" "[?]" "\'&\'"'))
+ result = @scope.function_shellquote( ['/etc/passwd ', '(ls)', '*', '[?]', "'&'"])
+ result.should(eql( '"/etc/passwd " "(ls)" "*" "[?]" "\'&\'"'))
end
it "should deal with double quotes" do
result = @scope.function_shellquote(
- ['"foo"bar"'])
+ ['"foo"bar"'])
result.should(eql(
'\'"foo"bar"\''))
end
it "should cope with dollar signs" do
- result = @scope.function_shellquote(
- ['$PATH', 'foo$bar', '"x$"'])
- result.should(eql(
- "'$PATH' 'foo$bar' '\"x$\"'"))
+ result = @scope.function_shellquote( ['$PATH', 'foo$bar', '"x$"'])
+ result.should(eql( "'$PATH' 'foo$bar' '\"x$\"'"))
end
it "should deal with apostrophes (single quotes)" do
result = @scope.function_shellquote(
- ["'foo'bar'", "`$'EDITOR'`"])
+ ["'foo'bar'", "`$'EDITOR'`"])
result.should(eql(
'"\'foo\'bar\'" "\\`\\$\'EDITOR\'\\`"'))
end
it "should cope with grave accents (backquotes)" do
- result = @scope.function_shellquote(
- ['`echo *`', '`ls "$MAILPATH"`'])
- result.should(eql(
- "'`echo *`' '`ls \"$MAILPATH\"`'"))
+ result = @scope.function_shellquote( ['`echo *`', '`ls "$MAILPATH"`'])
+ result.should(eql( "'`echo *`' '`ls \"$MAILPATH\"`'"))
end
it "should deal with both single and double quotes" do
- result = @scope.function_shellquote(
- ['\'foo"bar"xyzzy\'', '"foo\'bar\'xyzzy"'])
- result.should(eql(
- '"\'foo\\"bar\\"xyzzy\'" "\\"foo\'bar\'xyzzy\\""'))
+ result = @scope.function_shellquote( ['\'foo"bar"xyzzy\'', '"foo\'bar\'xyzzy"'])
+ result.should(eql( '"\'foo\\"bar\\"xyzzy\'" "\\"foo\'bar\'xyzzy\\""'))
end
it "should handle multiple quotes *and* dollars and backquotes" do
- result = @scope.function_shellquote(
- ['\'foo"$x`bar`"xyzzy\''])
- result.should(eql(
- '"\'foo\\"\\$x\\`bar\\`\\"xyzzy\'"'))
+ result = @scope.function_shellquote( ['\'foo"$x`bar`"xyzzy\''])
+ result.should(eql( '"\'foo\\"\\$x\\`bar\\`\\"xyzzy\'"'))
end
it "should handle linefeeds" do
- result = @scope.function_shellquote(
- ["foo \n bar"])
- result.should(eql(
- "\"foo \n bar\""))
+ result = @scope.function_shellquote( ["foo \n bar"])
+ result.should(eql( "\"foo \n bar\""))
end
end