diff options
author | brian <brian@FreeBSD.org> | 2000-08-09 09:23:30 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2000-08-09 09:23:30 +0000 |
commit | f67f88e23938af1d9e3e65d426081e1534e3703f (patch) | |
tree | 5882d7c6c4461276b4a9c649304de5fa912c770c /etc/rc | |
parent | c1fe03bbd9a9840ae3d7ad6422d8c7e0006d3405 (diff) | |
download | FreeBSD-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/rc')
-rw-r--r-- | etc/rc | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 |