From 4f41d620daa278907dbf68353381775bb29d302e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 30 Sep 2013 15:57:27 -0400 Subject: [PATCH] [COOK-3638] Do not use bashisms Signed-off-by: Seth Vargo --- files/default/tests/minitest/cron_test.rb | 4 ++-- recipes/cron.rb | 6 ++---- .../files/default/tests/minitest/cook-2086_test.rb | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/files/default/tests/minitest/cron_test.rb b/files/default/tests/minitest/cron_test.rb index c8e11b47..f8140442 100644 --- a/files/default/tests/minitest/cron_test.rb +++ b/files/default/tests/minitest/cron_test.rb @@ -28,10 +28,10 @@ it 'creates the cron command' do if node['chef_client']['cron']['use_cron_d'] - file("/etc/cron.d/chef-client").must_match %r{/bin/sleep \d+; (([A-Za-z]+=.*)?) /usr/bin/chef-client &> /dev/null} + file("/etc/cron.d/chef-client").must_match %r{/bin/sleep \d+; (([A-Za-z]+=.*)?) /usr/bin/chef-client > /dev/null 2>&1} else cron("chef-client").command. - must_match %r{/bin/sleep \d+; (([A-Za-z]+=.*)?)|[\s] /usr/bin/chef-client &> /dev/null} + must_match %r{/bin/sleep \d+; (([A-Za-z]+=.*)?)|[\s] /usr/bin/chef-client > /dev/null 2>&1} end end end diff --git a/recipes/cron.rb b/recipes/cron.rb index 197575c3..d1631837 100644 --- a/recipes/cron.rb +++ b/recipes/cron.rb @@ -85,8 +85,7 @@ class ::Chef::Recipe hour node['chef_client']['cron']['hour'] path node['chef_client']['cron']['path'] if node['chef_client']['cron']['path'] user "root" - shell "/bin/bash" - command "/bin/sleep #{sleep_time}; #{env} #{client_bin} &> #{log_file}" + command "/bin/sleep #{sleep_time}; #{env} #{client_bin} > #{log_file} 2>&1" end else cron_d "chef-client" do @@ -98,7 +97,6 @@ class ::Chef::Recipe hour node['chef_client']['cron']['hour'] path node['chef_client']['cron']['path'] if node['chef_client']['cron']['path'] user "root" - shell "/bin/bash" - command "/bin/sleep #{sleep_time}; #{env} #{client_bin} &> #{log_file}" + command "/bin/sleep #{sleep_time}; #{env} #{client_bin} > #{log_file} 2>&1" end end diff --git a/test/cookbooks/chef-client_test/files/default/tests/minitest/cook-2086_test.rb b/test/cookbooks/chef-client_test/files/default/tests/minitest/cook-2086_test.rb index fea09fef..c5ad583e 100644 --- a/test/cookbooks/chef-client_test/files/default/tests/minitest/cook-2086_test.rb +++ b/test/cookbooks/chef-client_test/files/default/tests/minitest/cook-2086_test.rb @@ -24,6 +24,6 @@ include Helpers::ChefClient it 'adds environment variables to the cron command' do cron("chef-client").command. - must_match %r{/bin/sleep \d+; FOO=BAR /usr/bin/chef-client &> /dev/null} + must_match %r{/bin/sleep \d+; FOO=BAR /usr/bin/chef-client > /dev/null 2>&1} end end