diff options
author | jkeiser <jkeiser@opscode.com> | 2013-01-16 11:01:41 -0800 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-06-07 13:12:20 -0700 |
commit | f35c1a48f4098185dc6feefc7c2e80d4311f770e (patch) | |
tree | 48d67185d290d0a5a824c363d1187f91bc3ce526 /lib/chef/knife/show.rb | |
parent | 5cf1446795ceaefb7e926726eb27f38bd19a69b2 (diff) | |
download | chef-f35c1a48f4098185dc6feefc7c2e80d4311f770e.tar.gz |
Make knife show exit with error code on error
Diffstat (limited to 'lib/chef/knife/show.rb')
-rw-r--r-- | lib/chef/knife/show.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/chef/knife/show.rb b/lib/chef/knife/show.rb index 9425da845e..df9a8b6516 100644 --- a/lib/chef/knife/show.rb +++ b/lib/chef/knife/show.rb @@ -1,5 +1,6 @@ require 'chef/chef_fs/knife' require 'chef/chef_fs/file_system' +require 'chef/chef_fs/file_system/not_found_error' class Chef class Knife @@ -15,21 +16,30 @@ class Chef def run # Get the matches (recursively) + error = false pattern_args.each do |pattern| Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern) do |result| if result.dir? - ui.error "#{result.path_for_printing}: is a directory" if pattern.exact_path + ui.error "#{format_path(result)}: is a directory" if pattern.exact_path + error = true else begin value = result.read - output "#{result.path_for_printing}:" + output "#{format_path(result)}:" output(format_for_display(value)) + rescue Chef::ChefFS::FileSystem::OperationNotAllowedError => e + ui.error "#{format_path(e.entry)}: #{e.reason}." + error = true rescue Chef::ChefFS::FileSystem::NotFoundError => e - ui.error "#{e.entry.path_for_printing}: No such file or directory" + ui.error "#{format_path(e.entry)}: No such file or directory" + error = true end end end end + if error + exit 1 + end end end end |