1. 15 Apr, 2021 38 commits
  2. 13 Apr, 2021 1 commit
  3. 12 Apr, 2021 1 commit
    • Marek Vasut's avatar
      cmd: exit: Fix return value · 8c4e3b79
      Marek Vasut authored
      In case exit is called in a script without parameter, the command
      returns -2 ; in case exit is called with a numerical parameter,
      the command returns -2 and lower. This leads to the following problem:
      => setenv foo 'echo bar ; exit 1' ; run foo ; echo $?
      bar
      0
      => setenv foo 'echo bar ; exit 0' ; run foo ; echo $?
      bar
      0
      => setenv foo 'echo bar ; exit -2' ; run foo ; echo $?
      bar
      0
      That is, no matter what the 'exit' command argument is, the return
      value is always 0 and so it is not possible to use script return
      value in subsequent tests.
      
      Fix this and simplify the exit command such that if exit is called with
      no argument, the command returns 0, just like 'true' in cmd/test.c. In
      case the command is called with any argument that is positive integer,
      the argument is set as return value.
      => setenv foo 'echo bar ; exit 1' ; run foo ; echo $?
      bar
      1
      => setenv foo 'echo bar ; exit 0' ; run foo ; echo $?
      bar
      0
      => setenv foo 'echo bar ; exit -2' ; run foo ; echo $?
      bar
      0
      
      Note that this do...
      8c4e3b79