我试图编写一个脚本来使用 gentoos java-config 编译 java 文件,但我最终得到一个错误 zsh: parse error: condition expected: "$1" 谁能告诉我这是什么意思以及为什么它会在第 16 行报告功能。
function jComp() {
local java_mods = ""
if (( $# == 0)); then
echo "using javac on .java in folder"
`javac *.java`
return 0
elif [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: jComp [java modules] [file]"
echo
echo "Options:"
echo " -h, This help message."
echo "modules has to be in the (java-config -l) list"
echo
echo "Report bugs to <tellone.diloom@gmail.com>."
return 0
fi
if [[ "$(java-config -v)" == "" ]]; then
echo "This script depends on java-config"
return 1
elif [[ "$1" =="-d" ]] || [[ "$1" == "--default"]]; then
`javac -cp .:$(java-config -p junit-4) *.java`
if [[ $# == 2 ]]; then
`javac -c .:$(java-config -p junit-4) "$2"`
return 0
fi
fi
while (( $# > 1 )); do
if [[ ! -f "$1" ]]; then
java_mods="$java_mods $1"
shift
continue
fi
done
`javac -cp .:$(java-config $java_mods)`
return 0
}
欢迎链接和评论。提前致谢