summaryrefslogtreecommitdiffhomepage
path: root/build.subr
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-03-02 12:44:33 +0100
committerLucio Andrés Illanes Albornoz (arab, vxp) <l.illanes@gmx.de>2016-03-02 12:44:33 +0100
commitd824e1e651835014ce7c5d9b0c21f7bc403d5646 (patch)
treecab5a84dbd39e4c50f6190f67661d26af2c29edf /build.subr
parent0fdea6e043b65b79add983ab6b196b479c768e3d (diff)
downloadmidipix_build-d824e1e651835014ce7c5d9b0c21f7bc403d5646.tar.bz2
midipix_build-d824e1e651835014ce7c5d9b0c21f7bc403d5646.tar.xz
- Emit warnings whenever a potentially dangerous operation is invoked by the build scripts.
Currently, this only includes rm_if_exists(). - Adds pedantic mode (-pt,) which additionally adds manual confirmation of each potentially dangerous operation.
Diffstat (limited to 'build.subr')
-rw-r--r--build.subr19
1 files changed, 17 insertions, 2 deletions
diff --git a/build.subr b/build.subr
index 48560774..30a45fa8 100644
--- a/build.subr
+++ b/build.subr
@@ -75,8 +75,22 @@ find_with_no_paths() {
rm_if_exists() {
[ -z "${1#-m}" ] && { _rie_arg_m=1; shift; };
[ -z "${1#-c}" ] && { _rie_arg_c=1; shift; };
- [ -d ${1} -o -f ${1} ] && rm -rf ${1};
- [ ${_rie_arg_m:-0} -eq 1 ] && { mkdir ${1}; unset _rie_arg_m; };
+ if [ -d ${1} -o -f ${1} ]; then
+ log_msg warn "Removing directory or file \`${1}'.";
+ if [ ${ARG_PEDANTIC:-0} -eq 1 ]; then
+ printf "Confirm deletion (y|N) ";
+ read _rie_prompt; case "${_rie_prompt}" in
+ [yY]) rm -rf ${1}; ;;
+ *) log_msg warn "Skipping removal of \`${1}'.";
+ _rie_arg_m=0; ;;
+ esac;
+ else
+ rm -rf ${1};
+ fi;
+ fi;
+ [ ${_rie_arg_m:-0} -eq 1 ] && {
+ log_msg warn "Making directory \`${1}'.";
+ mkdir ${1}; unset _rie_arg_m; };
[ ${_rie_arg_c:-0} -eq 1 ] && { cd ${1}; unset _rie_arg_c; };
return 0;
};
@@ -231,6 +245,7 @@ log_msg() {
fail) printf "\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
info) printf "\033[${LOG_MSG_INFO_COLOUR}m"; ;;
succ) printf "\033[${LOG_MSG_SUCC_COLOUR}m"; ;;
+ warn) printf "\033[${LOG_MSG_WARN_COLOUR}m"; ;;
esac;
if [ $# -gt 1 ]; then
printf "==> %s %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}" "$*";