aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2021-09-21 21:05:36 +0100
committerTomasz Kramkowski <tk@the-tk.com>2021-09-21 21:05:36 +0100
commit251047496c607548f8200ebf648039fa821e719b (patch)
treec651391fb0153839d884ba9215bc5acddf9ab9f9
parent08c899ae66b20cd05dc6e15efc3ba7efb689e720 (diff)
downloadpack-251047496c607548f8200ebf648039fa821e719b.tar.gz
pack-251047496c607548f8200ebf648039fa821e719b.tar.xz
pack-251047496c607548f8200ebf648039fa821e719b.zip
clean: always manually remove, use redo-targets to check
clean will now always use the non-redo-targets clean method, but if redo-targets is available it will check that there's nothing missing from the logic. This isn't bulletproof but it's better than having a working clean when using a redo with redo-targets and then having a broken clean logic because I forgot to add something when not using a redo-targets redo.
-rwxr-xr-xclean21
1 files changed, 15 insertions, 6 deletions
diff --git a/clean b/clean
index 930d2b6..9361998 100755
--- a/clean
+++ b/clean
@@ -1,8 +1,17 @@
-#!/bin/sh
+#!/bin/bash
+
if command -v redo-targets >/dev/null 2>&1; then
- redo-targets | tr '\n' '\0' | xargs -r0 rm -f
-else
- find . -type f \( -name '*.o' -o -name '*.inc' -o -name '*.tool' \) \
- -exec rm -f {} +
- rm -f .vars.rc all compile_flags.txt libpack test test_gen
+ mapfile -t targets < <(redo-targets)
fi
+
+rm -f .vars.rc all compile_commands.json libpack test test_gen
+find . -type f \
+ \( -name '*.cmd' -o -name '*.inc' -o -name '*.o' -o -name '*.tool' \) \
+ -delete
+
+for t in "${targets[@]}"; do
+ if [ -e "$t" ]; then
+ echo "$0: Missed '$t'. Removing!" >&2
+ rm "$t"
+ fi
+done