summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2000-08-09 09:23:30 +0000
committerbrian <brian@FreeBSD.org>2000-08-09 09:23:30 +0000
commitf67f88e23938af1d9e3e65d426081e1534e3703f (patch)
tree5882d7c6c4461276b4a9c649304de5fa912c770c /etc
parentc1fe03bbd9a9840ae3d7ad6422d8c7e0006d3405 (diff)
downloadFreeBSD-src-f67f88e23938af1d9e3e65d426081e1534e3703f.zip
FreeBSD-src-f67f88e23938af1d9e3e65d426081e1534e3703f.tar.gz
Improve purgedir():
Fix leading & trailing space handling Suggested by: ben Handle files beginning with - correctly Don't follow symlinks (cd /var/spool/lock; ln -s /. horror)
Diffstat (limited to 'etc')
-rw-r--r--etc/rc8
1 files changed, 5 insertions, 3 deletions
diff --git a/etc/rc b/etc/rc
index 360bc86..efa5ecf 100644
--- a/etc/rc
+++ b/etc/rc
@@ -165,10 +165,12 @@ purgedir() {
for dir
do
(
- cd "$dir" && ls | while read file
+ cd "$dir" && for file in .* *
do
- [ -d "$file" ] && purgedir "$file"
- [ -f "$file" ] && rm -f "$file"
+ [ ."$file" = .. -o ."$file" = ... ] && continue
+ [ -d "$file" -a ! -L "$file" ] &&
+ purgedir "$file"
+ [ -f "$file" ] && rm -f -- "$file"
done
)
done
OpenPOWER on IntegriCloud