summaryrefslogtreecommitdiff
path: root/lib/chef/knife/search.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/knife/search.rb')
-rw-r--r--lib/chef/knife/search.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb
index 654f9ad498..c4c3380734 100644
--- a/lib/chef/knife/search.rb
+++ b/lib/chef/knife/search.rb
@@ -108,7 +108,7 @@ class Chef
rescue Net::HTTPServerException => e
msg = Chef::JSONCompat.from_json(e.response.body)["error"].first
ui.error("knife search failed: #{msg}")
- exit 1
+ exit 99
end
if ui.interchange?
@@ -123,6 +123,9 @@ class Chef
end
end
end
+
+ # return a "failure" code to the shell so that knife search can be used in pipes similar to grep
+ exit 1 if result_count == 0
end
def read_cli_args