出於某種原因,這個功能是否工作正常,終端輸出的bash語法錯誤: 「(」 意外
newbootstrap.sh: 2: Syntax error: "(" unexpected
這裏是我的代碼(2號線是功能MoveToTarget() {
)
#!/bin/bash
function MoveToTarget() {
#This takes to 2 arguments: source and target
cp -r -f "$1" "$2"
rm -r -f "$1"
}
function WaitForProcessToEnd() {
#This takes 1 argument. The PID to wait for
#Unlike the AutoIt version, this sleeps 1 second
while [ $(kill -0 "$1") ]; do
sleep 1
done
}
function RunApplication() {
#This takes 1 application, the path to the thing to execute
exec "$1"
}
#our main code block
pid="$1"
SourcePath="$2"
DestPath="$3"
ToExecute="$4"
WaitForProcessToEnd $pid
MoveToTarget $SourcePath, $DestPath
RunApplication $ToExecute
exit
謝謝!現在有道理。我看到一些網站這樣做。 – rsmith 2011-06-14 16:53:20
@rsmith那個網站是不正確的,那麼。 – 2011-06-14 16:53:45
@rsmith命名的網站,或者是一個夢:-) – Jens 2016-03-02 21:00:34