1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-20 10:53:23 -07:00
rc/sh/disowned

44 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env sh
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
disowned() { ### @- find files in system directories that aren't associated with any pacman packages.
#
# Lists Pacman disowned files.
#
# Authors:
# Benjamin Boudreau <dreurmail@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
TMPDIR=/tmp
local tmp="$TMPDIR/pacman-disowned-$UID-$$"
mkdir -p "$tmp"
#trap 'rm -rf "$tmp"' EXIT # dangerous, needs fixing
pacman --quiet --query --list | sort -u > "$tmp/db"
if [ -n "$MSYSTEM" ]; then
# this excludes /bin due to confusion over symlinks.
# /lib and /sbin don't exist.
set -- /clang32 /clang64 /clangarm64 /etc /mingw32 /mingw64 /ucrt64 /usr
else
set -- /bin /etc /lib /sbin /usr
fi
find "$@" ! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) \
| grep -v '^/etc/pacman.d/gnupg/' \
| grep -v '^/usr/busybox/' \
| grep -v '/__pycache__/' \
| sort -u \
> "$tmp/fs"
comm -23 "$tmp/fs" "$tmp/db"
}
[ -n "${preload+-}" ] || disowned "$@"