Is there a way to make the command make clean
require user confirmation? I mistakenly executed it and now I have to wait 6 hours for the build to complete again.
The Makefile
s were created by cmake
.
Desired workflow:
> make clean
> [make] Are you sure you want to remove all the built files? [Y/N]
> N
> [make] Target 'make clean' not executed.
> make clean
> [make] Are you sure you want to remove all the built files? [Y/N]
> Y
> [make] Target 'make clean' executed.
I'm not familiar with cmake, but for gnu make, one possible hack would be:
clean: check_clean
check_clean:
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
.PHONY: clean check_clean
If check_clean
fails (user does not type in y
), then make will exit with an error before performing the clean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With