logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

exit.1p (4366B)


  1. '\" et
  2. .TH EXIT "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. exit
  12. \(em cause the shell to exit
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. exit \fB[\fIn\fB]\fR
  17. .fi
  18. .SH DESCRIPTION
  19. The
  20. .IR exit
  21. utility shall cause the shell to exit from its current execution
  22. environment with the exit status specified by the unsigned decimal integer
  23. .IR n .
  24. If the current execution environment is a subshell environment, the
  25. shell shall exit from the subshell environment with the specified exit
  26. status and continue in the environment from which that subshell
  27. environment was invoked; otherwise, the shell utility shall terminate
  28. with the specified exit status. If
  29. .IR n
  30. is specified, but its value is not between 0 and 255 inclusively, the
  31. exit status is undefined.
  32. .P
  33. A
  34. .IR trap
  35. on
  36. .BR EXIT
  37. shall be executed before the shell terminates, except when the
  38. .IR exit
  39. utility is invoked in that
  40. .IR trap
  41. itself, in which case the shell shall exit immediately.
  42. .SH OPTIONS
  43. None.
  44. .SH OPERANDS
  45. See the DESCRIPTION.
  46. .SH STDIN
  47. Not used.
  48. .SH "INPUT FILES"
  49. None.
  50. .SH "ENVIRONMENT VARIABLES"
  51. None.
  52. .SH "ASYNCHRONOUS EVENTS"
  53. Default.
  54. .SH STDOUT
  55. Not used.
  56. .SH STDERR
  57. The standard error shall be used only for diagnostic messages.
  58. .SH "OUTPUT FILES"
  59. None.
  60. .SH "EXTENDED DESCRIPTION"
  61. None.
  62. .SH "EXIT STATUS"
  63. The exit status shall be
  64. .IR n ,
  65. if specified, except that the behavior is unspecified if
  66. .IR n
  67. is not an unsigned decimal integer or is greater than 255. Otherwise,
  68. the value shall be the exit value of the last command executed, or
  69. zero if no command was executed. When
  70. .IR exit
  71. is executed in a
  72. .IR trap
  73. action, the last command is considered to be the command that executed
  74. immediately preceding the
  75. .IR trap
  76. action.
  77. .SH "CONSEQUENCES OF ERRORS"
  78. Default.
  79. .LP
  80. .IR "The following sections are informative."
  81. .SH "APPLICATION USAGE"
  82. None.
  83. .SH EXAMPLES
  84. Exit with a
  85. .IR true
  86. value:
  87. .sp
  88. .RS 4
  89. .nf
  90. exit 0
  91. .fi
  92. .P
  93. .RE
  94. .P
  95. Exit with a
  96. .IR false
  97. value:
  98. .sp
  99. .RS 4
  100. .nf
  101. exit 1
  102. .fi
  103. .P
  104. .RE
  105. .P
  106. Propagate error handling from within a subshell:
  107. .sp
  108. .RS 4
  109. .nf
  110. (
  111. command1 || exit 1
  112. command2 || exit 1
  113. exec command3
  114. ) > outputfile || exit 1
  115. echo "outputfile created successfully"
  116. .fi
  117. .P
  118. .RE
  119. .SH "RATIONALE"
  120. As explained in other sections, certain exit status values have been
  121. reserved for special uses and should be used by applications only for
  122. those purposes:
  123. .IP "\0126" 8
  124. A file to be executed was found, but it was not an executable utility.
  125. .IP "\0127" 8
  126. A utility to be executed was not found.
  127. .IP >128 8
  128. A command was interrupted by a signal.
  129. .P
  130. The behavior of
  131. .IR exit
  132. when given an invalid argument or unknown option is unspecified,
  133. because of differing practices in the various historical
  134. implementations. A value larger than 255 might be truncated by the
  135. shell, and be unavailable even to a parent process that uses
  136. \fIwaitid\fR()
  137. to get the full exit value. It is recommended that implementations
  138. that detect any usage error should cause a non-zero exit status (or,
  139. if the shell is interactive and the error does not cause the shell to
  140. abort, store a non-zero value in
  141. .BR \(dq$?\(dq ),
  142. but even this was not done historically in all shells.
  143. .SH "FUTURE DIRECTIONS"
  144. None.
  145. .SH "SEE ALSO"
  146. .IR "Section 2.14" ", " "Special Built-In Utilities"
  147. .\"
  148. .SH COPYRIGHT
  149. Portions of this text are reprinted and reproduced in electronic form
  150. from IEEE Std 1003.1-2017, Standard for Information Technology
  151. -- Portable Operating System Interface (POSIX), The Open Group Base
  152. Specifications Issue 7, 2018 Edition,
  153. Copyright (C) 2018 by the Institute of
  154. Electrical and Electronics Engineers, Inc and The Open Group.
  155. In the event of any discrepancy between this version and the original IEEE and
  156. The Open Group Standard, the original IEEE and The Open Group Standard
  157. is the referee document. The original Standard can be obtained online at
  158. http://www.opengroup.org/unix/online.html .
  159. .PP
  160. Any typographical or formatting errors that appear
  161. in this page are most likely
  162. to have been introduced during the conversion of the source files to
  163. man page format. To report such errors, see
  164. https://www.kernel.org/doc/man-pages/reporting_bugs.html .