copy-firmware.sh: warn if the destination folder is not empty

If the user provides an existing non-empty folder (their /usr/lib/firmware/ or otherwise)
there is a high chance we'll silently overwrite existing files. That may or may not be what
they wanted, so throw a warning so highlight that.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240923-misc-fixes-v2-12-397f23443628@gmail.com
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
This commit is contained in:
Emil Velikov 2024-09-23 14:09:40 +01:00 committed by Mario Limonciello
parent 8ff980be17
commit bf54edbe87

View file

@ -16,6 +16,10 @@ err() {
exit 1
}
warn() {
echo "WARNING: $*"
}
while test $# -gt 0; do
case $1 in
-v | --verbose)
@ -63,6 +67,10 @@ if test -z "$destdir"; then
err "destination directory was not specified"
fi
if test -d "$destdir"; then
find "$destdir" -type d -empty >/dev/null || warn "destination folder is not empty."
fi
# shellcheck disable=SC2162 # file/folder name can include escaped symbols
grep -E '^(RawFile|File):' WHENCE | sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' | while read k f; do
test -f "$f" || continue