summaryrefslogtreecommitdiff
path: root/Doc/help/return
blob: 4f7c6abd246c76181d13d3adb0cba873e4eb8d8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
return [ n ]
       Causes  a shell function or `.' script to return to the invoking
       script with the return status specified by an arithmetic expres-
       sion n.  For example, the following prints `42':

              () { integer foo=40; return "foo + 2" }
              echo $?

       If  n  is omitted, the return status is that of the last command
       executed.

       If return was executed from a trap in a  TRAPNAL  function,  the
       effect  is  different for zero and non-zero return status.  With
       zero status (or after an implicit  return  at  the  end  of  the
       trap),  the shell will return to whatever it was previously pro-
       cessing; with a non-zero status, the shell will behave as inter-
       rupted  except  that  the return status of the trap is retained.
       Note that the numeric value of the signal which caused the  trap
       is  passed  as  the  first  argument,  so  the statement `return
       "128+$1"' will return the same status as if the signal  had  not
       been trapped.