diff options
Diffstat (limited to 'config.rc')
-rw-r--r-- | config.rc | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -39,6 +39,8 @@ setv EMACS = emacs setv MAKEINFO = makeinfo # Helper functions +target=$1 basename=$2 dest=$3 + redo_clean() { # Clean function for various redo implementations [ -r .do_built ] && { @@ -52,15 +54,24 @@ redo_clean() { [ "$REDO_BASE" ] || rm -rf -- .redo } +targcheck() { + # Usage: targcheck [target...] + # + # Check if current target is one of the given arguments of this function. + # Returns 0 if target is one of the arguments, returns 1 if not. + case " $* " in *" $target "*) return 0; esac; return 1 +} + PHONY() { - # Function that resembles the .PHONY: target on the classic 'make' build - # system. - [ "$1" ] || { - trap 'rm -f $3' EXIT INT - return 0 - } - setv PHONY += "$@" - trap 'case " $PHONY " in *" $1 "*) rm -f $3; esac' EXIT INT + # Usage: PHONY [[target...]] + # + # Function that resembles the .PHONY: target on the classic 'make' system. + # You can either use it without an argument on a single target, or specify + # multiple targets. + if [ -z "$1" ] || targcheck "$@"; then + # shellcheck disable=2064 + trap "rm -f $dest" EXIT INT + fi } getbin() { |