我正在尝试通过bash脚本在中止上执行“not”,以便当被调用的脚本返回ok时它会中止,反之亦然,它不会中止。
我正在尝试这个
var newWindowRef = $window.open(url, name);
if (newWindowRef) {
if (newWindowRef.document.body) { // not working on IE
newWindowRef.document.title = "Downloading ...";
newWindowRef.document.body.innerHTML = '<h4>Your file is generating ... please wait</h4>';
}
var interval = setInterval(function() {
if (!!newWindowRef.closed) {
// Downloading completed
clearInterval(interval);
}
}, 1000);
} else {
$log.error("Opening new window is probably blocked");
}
但我不知道如何将两者结合起来。
答案 0 :(得分:3)
if my_process; then
echo "Program did not fail as expected. Bad!"
exit -1
else
echo "Program failed as expected. Good!"
fi
答案 1 :(得分:2)
作为if
/ else
的替代方案,您可以将&&
和||
运算符与groups命令一起使用:
my_process && { echo "Program did not fail as expected. Bad!"; exit -1; } \
|| echo "Program failed as expected. Good!"
答案 2 :(得分:2)
使用你的速记延伸约翰的回答:
! my_process && echo "Program failed as expected. Good!" || echo "Program did not fail as expected. Bad!" && exit -1
!
运算符否定条件布尔值,因此您可以使用&& .. || ..
。
编辑请注意,这并不像John更有用的代码那么清晰 - 只是为了表明您可以使用三元风格的语法。更喜欢John's answer的可读性。