#!/bin/sh
#
# cmd - takes input file, reads lines and discards lines start with hash
# then it takes first line as a command and remaining lines as arguments.
# the command with arguments is executed, and the return value forwarded.
#
# syntax:
#     cmd file.cmd
#
# you can also use shebang syntax in .cmd file

code=$(grep -Pv '^ *#.*' "$1" | grep -Pv '^ *$')
cmd=$(echo "${code}" | tr '\n' ' ')

# print() { printf '%s\n' "$*" >&2; }
# print "${code}"

printf '%b\n' "${code}\n"
bash -c "${cmd}"
exit $?
