我编写了一个脚本来自动化命令行参数以归档事物(基于来自som-snytt 的A )。它在带有MSYS的 win 7 上进行了测试,但它也应该在 Linux 上运行。
bash-3.1$ repl "import sys.error"
Loading C:\Users\xxx\AppData\Local\Temp\tmp.GgEjauEqwz...
import sys.error
Welcome to Scala version 2.10.0 (Java HotSpot(TM) Client VM, Java 1.7.0_07).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :impo
1) import scala.Predef._ (162 terms, 78 are implicit)
2) import sys.error (2 terms)
#!/bin/bash
function crash {
echo "Error: $1"
exit 10
}
if [ $# -ne 1 ]; then
echo "Script requires one parameter."
exit 1
fi
t=$(mktemp) || crash "Unable to create a temp file."
[ ${#t} -lt 1 ] && crash "Suspiciously short file name, aborting."
trap "rm -f -- '$t'" EXIT
echo "$1" > "$t"
scala -i "$t" || crash "Something wrong with scala binary."
rm -f -- "$t"
trap - EXIT
exit