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:
parent
0edeb3dc90
commit
3ebdf3366d
8
etc/rc
8
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
|
||||
|
Loading…
Reference in New Issue
Block a user