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)
This commit is contained in:
Brian Somers 2000-08-09 09:23:30 +00:00
parent 0edeb3dc90
commit 3ebdf3366d

8
etc/rc
View File

@ -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