linux-firmware/debian-firmware/debian/scripts/check-symlinks

23 lines
435 B
Plaintext
Raw Normal View History

2023-02-23 21:02:13 +01:00
#!/bin/bash -eu
#
# Check for dangling symlinks
#
if [ $# -ne 1 ] ; then
echo "Usage: check-symlinks <dirname>" >&2
exit 2
fi
if ! [ -d "${1}" ] ; then
echo "No such directory: ${1}" >&2
exit 1
fi
echo "Check for dangling symlinks in ${1} ..."
if [ "$(find "${1}" -xtype l | wc -l)" -ne 0 ] ; then
echo "Error: Dangling symlinks found" >&2
find "${1}" -xtype l
2023-03-04 10:58:02 +01:00
find . -xtype l -exec rm {} \; && exit 0 || exit 1
2023-02-23 21:02:13 +01:00
fi