我有一个效果很好的简单脚本(并打印hello
)
variable=false
if [ "$variable" = "false" ]; then
echo hello
fi
但是,这不起作用(并且不会打印hello
)
variable=$(source script.sh \
| awk -F":" '/maintenanceMode\>/ { print $2i }' \
| sed 's/,//g'
)
echo $variable # prints `false`, as expected
if [ "$variable" = "false" ]; then
echo hello
fi
我错过了什么?
答案 0 :(得分:0)
从变量中删除空格。
@objc func xButtonWasDragged(_ sender: UIPanGestureRecognizer) {
if sender.state == UIGestureRecognizerState.began || sender.state == UIGestureRecognizerState.changed {
self.view.bringSubview(toFront: xButton)
let translation = sender.translation(in: self.view)
//Move the view
xButton.center = CGPoint(x: xButton.center.x + translation.x, y: xButton.center.y)
distanceCounter += translation.x
//if moved left dont add to our distance counter
if distanceCounter < 0 {
distanceCounter = 0
}
// prevent button from moving left from start
if xButton.center.x < startingPointxBtn {
xButton.center.x = startingPointxBtn
} else if xButton.center.x > largeCircle.center.x && distanceCounter > xBtnDistance {
xButton.center.x = largeCircle.center.x
distanceCounter = xBtnDistance
// If we hit our target center and go over it in our distance counter
// make our distance be reached and forced to the center
} else {
// set the translation
sender.setTranslation(CGPoint.zero, in: self.view)
}
} else if sender.state == UIGestureRecognizerState.ended {
// If you let go of button within a distance, snap to center
if largeCircle.center.x - xButton.center.x <= 35.0 {
xButton.center = largeCircle.center
} else {
// if none of these conditions meet make it snap to start
xButton.center.x = startingPointxBtn
}
// reset our counter to always begin with zero
distanceCounter = 0
}
}