|
|
|
|
|
by frou_dh
2385 days ago
|
|
Here's a named task runner shellscript (as compared to a Makefile full of .PHONY being used as a named task runner). #!/bin/sh
set -e
case "$1" in
build)
;;
run)
;;
clean)
;;
*)
echo "unknown: $1"; exit 2
;;
esac
Someone else ITT hinted it could be done like the following. But the last line is dubious because it will happily run anything on PATH. #!/bin/sh
set -e
test $# -gt 0
build() {
:
}
run() {
:
}
clean() {
:
}
"$@"
|
|
Personally, I've never used PHONY, or had a need to.
That said, your bash examples are pretty simple - I especially like the 2nd example, as it would trivially allow having targets that ran other targets, e.g. an "all" target from a makefile:
``` all: build push
build: @docker build --tag ${IMG} --tag ${UNSTABLE} .
rebuild: @docker build --no-cache --tag ${IMG} --tag ${UNSTABLE} .
push: @docker push ${NAME} ```