【发布时间】:2011-09-14 21:11:55
【问题描述】:
由于某种原因,此功能运行正常。终端正在输出中
newbootstrap.sh:2:语法错误:“(”意外
这是我的代码(第 2 行是函数 MoveToTarget() {)
#!/bin/bash
function MoveToTarget() {
# This takes two arguments: source and target
cp -r -f "$1" "$2"
rm -r -f "$1"
}
function WaitForProcessToEnd() {
# This takes one argument. The PID to wait for
# Unlike the AutoIt version, this sleeps for one second
while [ $(kill -0 "$1") ]; do
sleep 1
done
}
function RunApplication() {
# This takes one 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
【问题讨论】:
-
Re"这个函数工作正常":你不是说"这个函数是 不是 正常工作”(我的重点)?
-
好的,OP 在 10 多年前离开了大楼。
标签: linux macos bash scripting syntax-error