Fix shellcheck errors/warnings
[range.git] / range.1
blob9fefa6334398cf77cfefb307b0e3f66354172a1c
1 .\" SPDX-License-Identifier: BSD-2-Clause
3 .\" Copyright (c) 2022 Alessio Chiapperini
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
26 .Dd April 20, 2022
27 .Dt RANGE 1
28 .Os
29 .Sh NAME
30 .Nm range
31 .Nd print a sequence of numbers or characters
32 .Sh SYNOPSIS
33 .Nm
34 .Fl h
35 .Op Fl s Ar sep
36 .Op Fl t Ar term
37 .Ar first
38 .Ar last
39 .Nm
40 .Fl h
41 .Op Fl s Ar sep
42 .Op Fl t Ar term
43 .Ar first
44 .Ar increment
45 .Ar last
46 .Sh DESCRIPTION
47 The
48 .Nm
49 utility prints numbers or characters from
50 .Ar first
52 .Ar last ,
53 in steps of
54 .Ar increment .
56 .Ar increment
57 is omitted, it defaults to either 1 or -1 depending on whether
58 .Ar first
59 is smaller than
60 .Ar last
61 or viceversa.
62 The sequence ends when the sum of the current element and
63 .Ar increment
64 would become greater than
65 .Ar last .
66 .Ar first ,
67 .Ar increment ,
68 and
69 .Ar last
70 are interpreted as signed integer values.
71 .Ar increment
72 is usually positive if
73 .Ar first 
74 is smaller than
75 .Ar last ,
76 and
77 .Ar increment
78 is usually negative if
79 .Ar first
80 is greater than
81 .Ar last .
82 .Ar increment
83 must be different than 0.
84 .Pp
85 The options are as follows:
86 .Bl -tag -width indent
87 .It Fl h
88 Print usage information and exit.
89 .It Fl s Ar sep
90 Use
91 .Ar sep
92 as the field delimiter in the sequence instead of
93 .Cm \en .
94 .It Fl t Ar term
95 Use
96 .Ar term
97 as the sequence terminator.
98 .El
99 .Sh "EXIT STATUS"
102 utility exits 0 on success, and 1 if an error occurs.
103 .Sh EXAMPLES
104 Print the sequence of even numbers from 0 to 100:
105 .Bd -literal -offset ident
106 $ range 0 2 100
109 Print the sequence of letters a-z separated by a comma:
110 .Bd -literal -offset ident
111 $ range -s , 'a' 'z'
115 Print the sequence of numbers from 10 to 5 with a default decrement of -1:
117 .Bd -literal -offset ident
118 $ range 10 5
122 Print the sequence of numbers from 1 to 10 separated by a horizontal tab and
123 terminated with a newline:
124 .Bd -literal -offset ident
125 $ range -s "\\t" -t "\\n" 1 10
128 .Sh SEE ALSO
129 .Xr seq 1
130 .Sh BUGS
131 The minimum and maximum values for the
132 .Ar first ,
133 .Ar last
135 .Ar increment
136 parameters are INT_MIN and INT_MAX respectively.
137 .Sh AUTHOR
138 .An Alessio Chiapperini Aq Mt alessio.chiapperini@\:nullbuffer.com