summaryrefslogtreecommitdiff
path: root/bin/locmaint
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-03-23 11:59:31 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-03-23 16:32:51 -0700
commit3f693e033d127930eade0fa1ac64fa753f283999 (patch)
tree6a64480e05377e063d3b58c65bdf6259a1974a81 /bin/locmaint
parentb4091e4020dbac74f502d2b8a1f150918159a2a1 (diff)
downloaddotfiles-3f693e033d127930eade0fa1ac64fa753f283999.tar.gz
locmaint: permit zero-size .keep when checking whether dirs empty
Diffstat (limited to 'bin/locmaint')
-rwxr-xr-xbin/locmaint9
1 files changed, 8 insertions, 1 deletions
diff --git a/bin/locmaint b/bin/locmaint
index 67eea85b..c182ace0 100755
--- a/bin/locmaint
+++ b/bin/locmaint
@@ -593,13 +593,20 @@ Check whether C<$dir> contains any hidden or unhidden files, returning
a true value if it does not, a false value if it does. If it does,
print them.
+As a special exception, ignore a zero-sized file named '.keep' (which
+is used to prevent empty directories getting clobbered by things like
+snap).
+
=cut
sub empty_dir_or_list {
my ($dir) = @_;
opendir(my $dirh, $dir);
- my @files = grep { $_ ne '.' && $_ ne '..' } readdir $dirh;
+ my @files
+ = grep $_ ne '.'
+ && $_ ne '..'
+ && !($_ eq ".keep" && -z catfile $dir, ".keep"), readdir $dirh;
if (@files == 0) {
return 1;