aboutsummaryrefslogtreecommitdiff
path: root/applets_sh
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-01-13 10:33:46 +0000
committerDenys Vlasenko <vda.linux@googlemail.com>2020-04-30 17:23:08 +0200
commit981b2eff814bd186188ad66a32990a6d17b37a3e (patch)
tree9d66d4de595eac03a479de13ea8a66daf69c87cd /applets_sh
parentda7a6dbfa5d78e3d5cec5906b402908505d0fcf9 (diff)
downloadbusybox-981b2eff814bd186188ad66a32990a6d17b37a3e.tar.gz
mim: run scripts from a specification file
mim runs scripts from a specification file which can be thought of as an extremely limited Makefile. Neither make variables nor dependencies are supported. By default the file 'Mimfile' is read. An example: hello: echo hello $1 clean: rm -rf * The command 'mim' or 'mim hello' will echo 'hello'. Unlike 'make' arguments after the first are available to the script; they don't specify additional targets. mim isn't enabled by default. Enabling it increases the size of the binary by about 500 bytes. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'applets_sh')
-rwxr-xr-xapplets_sh/mim39
1 files changed, 39 insertions, 0 deletions
diff --git a/applets_sh/mim b/applets_sh/mim
new file mode 100755
index 000000000..2a65c35bb
--- /dev/null
+++ b/applets_sh/mim
@@ -0,0 +1,39 @@
+#!/bin/sh
+MIMFILE="Mimfile"
+if [ $# -ge 2 ] && [ "$1" = "-f" ]
+then
+ MIMFILE="$2"
+ shift 2
+fi
+exec <"$MIMFILE" || exit 1
+{
+ INCASE=false
+ while read -r REPLY
+ do
+ case $REPLY in
+ *:)
+ if ! $INCASE
+ then
+ printf '[ $# -eq 0 ] && set -- "%s"
+TARGET="$1"
+shift
+case "$TARGET" in
+' "${REPLY%:}"
+ else
+ printf ';;\n'
+ fi
+ printf '%s)\n' "${REPLY%:}"
+ INCASE=true
+ ;;
+ "") ;;
+ *) printf '%s\n' "${REPLY##[ ]}";;
+ esac
+ done
+ $INCASE && printf ';;\n'
+ printf '*)
+echo "Unknown command $TARGET"
+exit 1
+;;
+esac
+'
+} | sh -s "$@"