diff options
| author | Xu Cheng | 2015-07-22 19:47:02 +0800 |
|---|---|---|
| committer | Xu Cheng | 2015-07-22 20:35:01 +0800 |
| commit | fd7f3b949659cedef62ac58258c652bea58ef1a7 (patch) | |
| tree | 80fad8da32a8105d29c795593ef05e1170269938 | |
| parent | ebd0f345619b6fd76751275b43a97d5ac5e11b76 (diff) | |
| download | brew-fd7f3b949659cedef62ac58258c652bea58ef1a7.tar.bz2 | |
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 <xucheng@me.com>
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 4 |
1 files changed, 3 insertions, 1 deletions
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 |
