I get $ ./5_divisible_by_1_to_10.sh ./5_divisible_by_1_to_10.sh: line 16: [: -eq: unary operator expected falsetruefor:divisible_by () {  under_test=$1  from=2  to=4  divisible=0  for ((check=from; check<=to; check++)) {    if [ $(($under_test % $check)) -ne 0 ]; then      divisible=1    fi    }  return $divisible}divider=10x= divisible_by $dividerif [ $x -eq 0 ]; then  # <--- Line 16  echo $x trueelse  echo $x falsefidivider=12if divisible_by $divider; then  echo trueelse  echo falsefiThe second call for 12 works ok but the first call using 10, where I am trying to display the result gives the error.Adding quotes around $x, i.e $x gives a different error: $ ./5_divisible_by_1_to_10.sh ./5_divisible_by_1_to_10.sh: line 16: [: : integer expression expected falsetrue
Why do I get -eq: unary operator expected false?
shell script
Inif [ $x -eq 0 ]x is empty because the linex= divisible_by $divideris wrong: It calls divisible_by with the empty environment variable x but doesn't even try to set x in the shell environment. You need:divisible_by $dividerx=$?And you should always quote your variables.