mercredi 9 janvier 2019

"set -e" and "test" in shell

In shell scripts set -e is often used to make them more robust by stopping the script when some of the commands executed from the script exits with non-zero exit code. I am confused about "set -e" and "test" commands,the result is contrary to what i want.

#!/bin/bash
set -e
a=10
b=9
#test $a -lt $b && false
#test $a -gt $b && false
echo "111"

The real result is: if a > b, print nothing if a < b, print 111. but i don't think so, i think the result is nothing whatever happened.

Aucun commentaire:

Enregistrer un commentaire