From 1475bc53a4757af1fca78dcf521dfd5f11d1a819 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Weism=C3=BCller?= Date: Fri, 10 Jan 2020 16:06:00 +0100 Subject: [PATCH] filesystem-cleanup: Add parameter to show changes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use --dry-run to only show files that would be deleted, but do not actually delete them. Signed-off-by: Daniel Weismüller Signed-off-by: Arne Fitzenreiter --- src/scripts/filesystem-cleanup | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/scripts/filesystem-cleanup b/src/scripts/filesystem-cleanup index d4cdfe8d3e..7e7accc7a2 100644 --- a/src/scripts/filesystem-cleanup +++ b/src/scripts/filesystem-cleanup @@ -27,6 +27,22 @@ PATHS=( ) main() { + local dry_run="false" + + while [ $# -gt 0 ]; do + case "${1}" in + --dry-run) + dry_run="true" + ;; + + *) + echo "${0}: Invalid argument: ${1}" >&2 + return 2 + ;; + esac + shift + done + # Update the runtime linker cache (this may fix any broken symlinks) ldconfig @@ -65,7 +81,12 @@ main() { ;; *) - unlink "${file}" + echo "Removing ${file}..." + + # Actually remove the file (maybe) + if [ "${dry_run}" = "false" ]; then + unlink "${file}" + fi ;; esac done -- 2.39.2