猛砸布尔变量检查报告说找不到命令

问题描述:

我有.sh扩展&在OSX环境中运行一个shell脚本,我已经建立了一个变量象下面这样:猛砸布尔变量检查报告说找不到命令

booean_var1 = false 
booean_var2 = true 

还有一个如果基于2检查变量

if [ $booean_var1 ] || [ $booean_var2 ] 
then 
    echo one of them is true 
fi 

在一台OSX机器上的bash上运行它工作正常。但是,我执行我的shell脚本从另一个OSX机器&庆典上运行它从那里说

booean_var1 command not found 

是否shell脚本语法从bash的不同从一台计算机到另一个?

+0

删除空间='' – anubhava

+0

[]'不测试一个字符串是否等于'true',只有当它非空时。 –

+0

'bash'没有布尔常量。 'true'和'false'是命令的名字。 – chepner

尝试没有空格:

booean_var1=false 
booean_var2=true 

而且由于truefalse是命令,whipe []:约`

if $booean_var1 || $booean_var2 ;then 
    echo one of them is true 
fi 
+0

谢谢。有效 –

booean_var1=false 
booean_var2=true 

if [ "$booean_var1" = true ] || [ "$booean_var2" = true ] 
then 
    echo one of them is true 
fi