我試圖編寫一個腳本來編譯帶有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 <[email protected]>."
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
}
歡迎鏈接和評論。在此先感謝