aboutsummaryrefslogtreecommitdiff
path: root/applets_sh/mim
blob: 2a65c35bb39e4c1227ef39ad5d1f25e36623bc6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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 "$@"