This is a resume of my code.ninja (){  if $1 = toto  then  return 1  elif $1 = tata  then  return 4  fi}main () {  ninja tata  if [ $? -ne 1 ]  then    somecode  fi}main $@For no reason, when my function return something, the program just exit (I've tested with a trap EXIT), the function return 4 and execute the trap.Thanks for your help.Edit : works when I commentset -o errexitset -o errtraceBut how Can I found the error ?
Program exit when return in a function
bash;exit;return status
If you want to test that function argument equivalent to some string, you must use construct if [ $x == string ], then your code will looks like:test () {  if [ $1 == toto ] then    return 1  elif [ $1 == tata ] then    return 4  fi}main () {  test tata  if [ $? -ne 1 ] then    echo somecode  fi}main $@And you could use test name for the function.  If you want to call builtin test, then use builtin test construct.And take care about = (assignment) and == (comparison).  Inside the test [ and ] the = operator works like == and tests the string equality (not numbers).set -o errexit exits immediately after command returns non-zero (non-succesful).  Your ninja returns 1 (which is non-zero) and exit.Your code without tests is not working cause if statement tries to execute instructions into it and determine the exit state of the command: if the exit state is zero (success), then execute instructions after then till elif of fi.