.\" .\" Copyright (c) 2008 .\" Jeffrey Allen Neitzel . .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY JEFFREY ALLEN NEITZEL ``AS IS'', AND ANY .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE .\" DISCLAIMED. IN NO EVENT SHALL JEFFREY ALLEN NEITZEL BE LIABLE FOR ANY .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE .\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" @(#)$looptest: version 20081030 by Jeffrey Allen Neitzel $ .\" .TH LOOPTEST 1 "October 30, 2008" "looptest-20081030" "General Commands" .SH NAME looptest \- loop iteration tester .SH SYNOPSIS .B looptest \fIcount\fR \fIfile\fR .SH DESCRIPTION The .B looptest utility counts the number of lines in the specified .I file and compares it with the specified .IR count . It exits with an appropriate status according to whether this comparison is equal or not equal. .PP Notice that this utility has the same effect as doing a: .PP .RS wc \-l <\fIfile\fR | tr \-d '\ \\t' | grep '^\fIcount\fR$' >/dev/null .RE .PP In fact, it is a direct replacement for this command line that provides a simpler, more efficient way for both .IR osh (1) and .IR sh6 (1) to perform count-controlled loops. .SH "EXIT STATUS" The .B looptest utility exits with one of the following values: .TP 0 The .I file line count is equal to .IR count . .TP 1 The .I file line count is not equal to .IR count . .TP 2 An error was detected. .SH "EXAMPLES" Each of the following command files causes the shell to perform a loop that prints 80 dots to the standard output. .PP .nf : Print dots with osh and sh6. ( : ) >prdots.$$ : Loop echo -n . echo >>prdots.$$ if ! { looptest 80 prdots.$$ } goto Loop echo ; rm -f prdots.$$ .fi .PP .I Osh also offers another way to test the .B looptest exit status with the `$s' special parameter as illustrated below. .PP .nf : Print dots with osh. ( : ) >prdots.$$ : Loop echo -n . echo >>prdots.$$ looptest 80 prdots.$$ if $s != 0 goto Loop echo ; rm -f prdots.$$ .fi .SH "SEE ALSO" osh(1), sh6(1) .PP Looptest home page: http://v6shell.org/looptest/ .SH AUTHOR This implementation of .B looptest is written by Jeffrey Allen Neitzel. .SH LICENSE See http://v6shell.org/looptest/LICENSE for full details.