From 3837dda23cf23111a92056ef862017bcf050a865 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 17 May 2015 22:47:05 +0000 Subject: process: implement array expansion to preserve spaces This can make it easier to specify mcompand parameters in socks, as those require separate levels of parameter parsing and require quoting in shell. --- test/test_env.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/test_env.rb b/test/test_env.rb index bd7961d..6b36f32 100644 --- a/test/test_env.rb +++ b/test/test_env.rb @@ -52,4 +52,20 @@ class TestEnv < Testcase res = env_expand({"PATH"=>"$PATH"}, expand: true) assert_equal ENV["PATH"], res["PATH"] end + + def test_ary + ENV['HELLO'] = 'HIHI' + ENV['PAATH'] = '/usr/local/bin:/usr/bin:/bin' + env = { 'BLAH' => [ '$HELLO/WORLD', '$PAATH', '$(echo hello world)' ] } + res = env_expand(env, expand: true) + exp = [ "HIHI/WORLD", ENV['PAATH'], 'hello world' ] + assert_equal exp, Shellwords.split(res['BLAH']) + env = { + 'BLAH' => [ '$(echo hello world)' ], + 'MOAR' => [ '$BLAH', 'OMG HALP SPACES' ] + } + res = env_expand(env, expand: true) + exp = ["hello\\ world", "OMG HALP SPACES"] + assert_equal exp, Shellwords.split(res['MOAR']) + end end -- cgit v1.2.3-24-ge0c7