Files
oldlinux-files/Ref-docs/POSIX/susv3/utilities/break.html
2024-02-19 00:21:47 -05:00

197 lines
4.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>break</title>
</head>
<body bgcolor="white">
<basefont size="3"> <a name="break"></a> <a name="tag_04_11"></a><!-- break -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_04_11_01"></a>NAME</h4>
<blockquote>break - exit from for, while, or until loop</blockquote>
<h4><a name="tag_04_11_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><code><tt>break</tt> <b>[</b><i>n</i><b>]</b></code></p>
</blockquote>
<h4><a name="tag_04_11_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>break</i> utility shall exit from the smallest enclosing <b>for</b>, <b>while</b>, or <b>until</b> loop, if any; or from
the <i>n</i>th enclosing loop if <i>n</i> is specified. The value of <i>n</i> is an unsigned decimal integer greater than or equal
to 1. The default shall be equivalent to <i>n</i>=1. If <i>n</i> is greater than the number of enclosing loops, the outermost
enclosing loop shall be exited. Execution shall continue with the command immediately following the loop.</p>
</blockquote>
<h4><a name="tag_04_11_04"></a>OPTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_05"></a>OPERANDS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_06"></a>STDIN</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_07"></a>INPUT FILES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_08"></a>ENVIRONMENT VARIABLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_09"></a>ASYNCHRONOUS EVENTS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_10"></a>STDOUT</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_11"></a>STDERR</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_12"></a>OUTPUT FILES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_13"></a>EXTENDED DESCRIPTION</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_14"></a>EXIT STATUS</h4>
<blockquote>
<dl compact>
<dt>&nbsp;0</dt>
<dd>Successful completion.</dd>
<dt>&gt;0</dt>
<dd>The <i>n</i> value was not an unsigned decimal integer greater than or equal to 1.</dd>
</dl>
</blockquote>
<h4><a name="tag_04_11_15"></a>CONSEQUENCES OF ERRORS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_04_11_16"></a>APPLICATION USAGE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_17"></a>EXAMPLES</h4>
<blockquote>
<pre>
<tt>for i in * do
if test -d "$i" then break fi done
</tt>
</pre>
</blockquote>
<h4><a name="tag_04_11_18"></a>RATIONALE</h4>
<blockquote>
<p>In early proposals, consideration was given to expanding the syntax of <i>break</i> and <a href=
"../utilities/continue.html"><i>continue</i></a> to refer to a label associated with the appropriate loop as a preferable
alternative to the <i>n</i> method. However, this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 does reserve the name space of command
names ending with a colon. It is anticipated that a future implementation could take advantage of this and provide something
like:</p>
<pre>
<tt>outofloop: for i in a b c d e
do
for j in 0 1 2 3 4 5 6 7 8 9
do
if test -r "${i}${j}"
then break outofloop
fi
done
done
</tt>
</pre>
<p>and that this might be standardized after implementation experience is achieved.</p>
</blockquote>
<h4><a name="tag_04_11_19"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_11_20"></a>SEE ALSO</h4>
<blockquote>
<p><a href="xcu_chap02.html#tag_02_14"><i>Special Built-In Utilities</i></a></p>
</blockquote>
<h4><a name="tag_04_11_21"></a>CHANGE HISTORY</h4>
<blockquote>
<p>None.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>