summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/lib.sh30
-rwxr-xr-xmk19
2 files changed, 34 insertions, 15 deletions
diff --git a/include/lib.sh b/include/lib.sh
index 812341f4..840c5cf5 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -27,6 +27,11 @@ update_xbmkver()
err "can't write '$versiondate'" "update_xbmkver" "$@"; :
}
+version()
+{
+ printf "%s\nWebsite: %s\n" "$relname" "$projectsite"
+}
+
xbmk_sanitize_version()
{
if [ -z "$version" ]; then
@@ -222,6 +227,31 @@ x_()
fi
}
+xeq()
+{
+ if [ $# -lt 2 ]; then
+ err "no args" xeq
+ fi
+ xbcmd="$1"
+ chk="$2"
+ shift 2
+
+ case "$chk" in
+ -*)
+ return 1
+ ;;
+ *)
+ for eq in "$@"; do
+ if [ "$chk" = "$eq" ]; then
+ return 0
+ fi
+ done
+ ;;
+ esac
+
+ err "bad command" xeq "$xbcmd" "$chk" "$@"
+}
+
xchk()
{
if [ $# -lt 3 ]; then
diff --git a/mk b/mk
index 78d2a603..286e24f9 100755
--- a/mk
+++ b/mk
@@ -35,26 +35,15 @@ main()
cmd=""
if [ $# -gt 0 ]; then
cmd="$1"
-
shift 1
fi
- case "$cmd" in
- version)
- printf "%s\nWebsite: %s\n" "$relname" "$projectsite"
- ;;
- release|download|inject|prep_mr_import)
- $cmd "$@"
- ;;
- -*)
+ if ! xeq main "$cmd" \
+ version release download inject prep_mr_import; then
return 0
- ;;
- *)
- err "bad command" main "$@"
- ;;
- esac
+ fi
- # some commands disable them. turn them back on!
+ $cmd "$@"
set -u -e
return 1