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>
This commit is contained in:
parent
ebd0f34561
commit
fd7f3b9496
@ -393,7 +393,9 @@ class Pathname
|
|||||||
out = ""
|
out = ""
|
||||||
n = Utils.popen_read("find", expand_path.to_s, "-type", "f", "!", "-name", ".DS_Store").split("\n").size
|
n = Utils.popen_read("find", expand_path.to_s, "-type", "f", "!", "-name", ".DS_Store").split("\n").size
|
||||||
out << "#{n} files, " if n > 1
|
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
|
out
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user