diff options
author | John Keiser <jkeiser@opscode.com> | 2013-04-06 12:51:13 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-06-07 13:12:30 -0700 |
commit | dd57d6f8705880ba686399440ca295c301b41e30 (patch) | |
tree | 043c76ec18925ad66d6399b99b385479fdb89c8a /lib/chef/knife/xargs.rb | |
parent | f70de1eea720ba5baf8ef2174aea6cb36214afa5 (diff) | |
download | chef-dd57d6f8705880ba686399440ca295c301b41e30.tar.gz |
Add xargs -0 for null separator, split on space as well as newline
Diffstat (limited to 'lib/chef/knife/xargs.rb')
-rw-r--r-- | lib/chef/knife/xargs.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/knife/xargs.rb b/lib/chef/knife/xargs.rb index f45164365f..d64ee9a169 100644 --- a/lib/chef/knife/xargs.rb +++ b/lib/chef/knife/xargs.rb @@ -62,6 +62,11 @@ class Chef :short => '-t', :description => "Print command to be run on the command line" + option :null_separator, + :short => '-0', + :boolean => true, + :description => "Use the NULL character (\0) as a separator, instead of whitespace" + def run error = false # Get the matches (recursively) @@ -134,8 +139,11 @@ class Chef def get_patterns if config[:patterns] [ config[:patterns] ].flatten + elsif config[:null_separator] + stdin.binmode + stdin.read.split("\000") else - stdin.lines.map { |line| line.chomp } + stdin.read.split(/\s+/) end end |