On 2019-08-13, "Theo de Raadt" <[email protected]> wrote:
>> Could you add '&& -d /mnt/usr/lib/clang' to check whether the directory
>> exists before trying to cd into it (similarly for /mnt/usr/bin/gcc and
>> gcc-libs)?
>
> Then might as well just -d only, and skip the -f
Seriously, why bother with a check in the first place?
If the glob fails to match, it will be passed unexpanded to rm, which
will fail silently. That's not different from syspatch/*.
Does anybody see a problem with this:
clean_old() {
local _cver
rm -rf /mnt/usr/lib/gcc-lib/!(*$VNAME)
_cver=$(cd /mnt/usr/lib/clang 2>/dev/null && ls -r | sed -e 1q) &&
rm -rf /mnt/usr/lib/clang/!($_cver)
rm -rf /mnt/var/syspatch/*
}
> But then people who mangle their system with symbolic links will lose
At most a symlink will be removed and the directory still exists
somewhere else. *shrug*
I don't think we should worry about such corner cases on nonstandard
systems.
--
Christian "naddy" Weisgerber [email protected]