From fd7f3b949659cedef62ac58258c652bea58ef1a7 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Wed, 22 Jul 2015 19:47:02 +0800 Subject: Pathname#abv: handle the case `du` returns empty string This can happen when read permission is denied. Fixes Homebrew/homebrew#41925. Closes Homebrew/homebrew#42011. Signed-off-by: Xu Cheng --- Library/Homebrew/extend/pathname.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index a0c24e981..40c6eba31 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -393,7 +393,9 @@ class Pathname out = "" n = Utils.popen_read("find", expand_path.to_s, "-type", "f", "!", "-name", ".DS_Store").split("\n").size out << "#{n} files, " if n > 1 - out << Utils.popen_read("/usr/bin/du", "-hs", expand_path.to_s).split("\t")[0].strip + size = Utils.popen_read("/usr/bin/du", "-hs", expand_path.to_s).split("\t")[0] + size ||= "0B" + out << size.strip out end -- cgit v1.2.3