Article 6CMAP [SOLVED] What is wrong with these If statements ?

[SOLVED] What is wrong with these If statements ?

by
pedropt
from LinuxQuestions.org on (#6CMAP)
hello everyone , i can not figure out why this does not work correctly , need some help .

Example script ahead , execute it and set var1 as 0 and var2 as 1 and the output will say that are both at 1 !!!

Code:#!/bin/bash
echo -n "Set Var 1 (0 or 1) : "
read -r var1
echo -n "Set Var 2 (0 or 1) : "
read -r var2

if [ "$var1" == "1" ] || [ "$var2" == "1" ]
then
echo "Both at 1"
elif [ "$var1" == "0" ] || [ "$var2" == "1" ]
then
echo "Var1 at 0 | var2 at 1"
elif [ "$var1" == "1" ] || [ "$var2" == "0" ]
then
echo "Var1 at 1 | var2 at 0"
elif [ "$var1" == "0" ] || [ "$var2" == "0" ]
then
echo "Both at 0"
fi
exit 0
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments