我想重新创建这样的东西
- if ( arg1 || arg2 || arg 3) {}
我确实到目前为止,但是我收到以下错误
- line 11: [.: command not found
- if [ $char == $';' -o $char == $'\\' -o $char == $'\'' ]
- then ...
我尝试了不同的方式,但似乎没有工作some of the ones I tried
对于bash,您可以使用[[]]形式而不是[],这允许&&和||内部:
- if [[ foo || bar || baz ]] ; then
- ...
- fi
否则,您可以在外部使用通常的布尔逻辑运算符:
- [ foo ] || [ bar ] || [ baz ]
…或使用特定于测试命令的操作(though modern versions of the POSIX specification describe this XSI extension as deprecated — see the APPLICATION USAGE section):
- [ foo -o bar -o baz ]
…这是以下不同的书面形式,它们同样被弃用:
- test foo -o bar -o baz