Skip to content

Commit

Permalink
[COOK-3638] Do not use bashisms
Browse files Browse the repository at this point in the history
Signed-off-by: Seth Vargo <sethvargo@gmail.com>
  • Loading branch information
glensc authored and sethvargo committed Sep 30, 2013
1 parent 68680fa commit 4f41d62
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions files/default/tests/minitest/cron_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions recipes/cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4f41d62

Please sign in to comment.