48 lines
717 B
Bash
Executable File
48 lines
717 B
Bash
Executable File
#!/bin/sh
|
|
|
|
_printhelp ()
|
|
{
|
|
cat<<EOF
|
|
Usage: ${1##*/} [OPTIONS] SCRIPT
|
|
|
|
Run Emacs Lisp SCRIPT.
|
|
|
|
Options:
|
|
|
|
-b: Byte-compile before running.
|
|
-c: Remove byte code once finished.
|
|
EOF
|
|
}
|
|
|
|
OPT_BYTE=false
|
|
OPT_CLEAN=false
|
|
while getopts :bc OPT; do
|
|
case $OPT in
|
|
b)
|
|
OPT_BYTE=true ;;
|
|
c)
|
|
OPT_CLEAN=true ;;
|
|
?)
|
|
_printhelp "$0"
|
|
exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
if [ $# -eq 0 ]; then
|
|
_printhelp "$0"
|
|
exit 1
|
|
fi
|
|
|
|
if $OPT_BYTE && [ "${1##*.}" = "el" ]; then
|
|
script="${1%.*}.elc"
|
|
emacs -Q --batch -f batch-byte-compile "$1"
|
|
else
|
|
script="$1"
|
|
OPT_CLEAN=false
|
|
fi
|
|
|
|
emacs -Q --script "$script"
|
|
|
|
$OPT_CLEAN && rm "$script"
|