Image

Imagecepcion wrote in Imagelinux 😟distressed

bash help, please.

Alright, Bash must have the pickiest syntax ever. I'm writing a little script to log idle times, and have an if block that checks for mouse/keyboard movement. code bit :
if [ "$OKEYB" != "$CKEYB" || "$OMOUS" != "$CMOUS" ]; then # pressed
   echo "some movement"
fi
edit got it. bash didn't like "||" for the or, so I used -o instead. Correct code:
if [ "$OKEYB" != "$CKEYB" -o "$OMOUS" != "$CMOUS" ]; then # pressed

running the script results in

./zombie.sh: line 33: [: missing `]'
./zombie.sh: line 33: : command not found
./zombie.sh: line 43: 1066246639-: syntax error: operand expected (error token is "-")
If I simplify the condition to just one or the other the script runs fine. Is there space or bracket that needs to be somewhere?