出于某种原因,这个功能是否工作正常,终端输出的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