1ckrange(1) User Commands ckrange(1)
2
3
4
6 ckrange, errange, helprange, valrange - prompts for and validates an
7 integer
8
10 ckrange [-Q] [-W width] [-l lower] [-u upper] [-b base]
11 [-d default] [-h help] [-e error] [-p prompt]
12 [-k pid [-s signal]]
13
14
15 /usr/sadm/bin/errange [-W width] [-e error] [-l lower]
16 [-u upper] [-b base]
17
18
19 /usr/sadm/bin/helprange [-W width] [-h help] [-l lower]
20 [-u upper] [-b base]
21
22
23 /usr/sadm/bin/valrange [-l lower] [-u upper] [-b base] input
24
25
27 The ckrange utility prompts a user for an integer between a specified
28 range and determines whether this response is valid. It defines, among
29 other things, a prompt message whose response should be an integer in
30 the range specified, text for help and error messages, and a default
31 value (which is returned if the user responds with a RETURN).
32
33
34 This command also defines a range for valid input. If either the lower
35 or upper limit is left undefined, then the range is bounded on only one
36 end.
37
38
39 All messages are limited in length to 79 characters and are formatted
40 automatically. Tabs and newlines are removed after a single whitespace
41 character in a message definition, but spaces are not removed. When a
42 tilde is placed at the beginning or end of a message definition, the
43 default text will be inserted at that point, allowing both custom text
44 and the default text to be displayed.
45
46
47 If the prompt, help or error message is not defined, the default mes‐
48 sage (as defined under EXAMPLES) is displayed.
49
50
51 Three visual tool modules are linked to the ckrange command. They are
52 errange (which formats and displays an error message on the standard
53 output), helprange (which formats and displays a help message on the
54 standard output), and valrange (which validates a response).
55
56
57 Note: Negative "input" arguments confuse getopt in valrange. By insert‐
58 ing a "−" before the argument, getopt processing will stop. See
59 getopt(1) and Intro(1) about getopt parameter handling. getopt is used
60 to parse positional parameters and to check for legal options.
61
63 The following options are supported:
64
65 -b base Defines the base for input. Must be 2 to 36, default is
66 10. Base conversion uses strtol(3C). Output is always
67 base 10.
68
69
70 -d default Defines the default value as default. default is con‐
71 verted using strtol(3C) in the desired base. Any charac‐
72 ters invalid in the specified base will terminate the
73 strtol conversion without error.
74
75
76 -e error Defines the error message as error.
77
78
79 -h help Defines the help message as help.
80
81
82 -k pid Specifies that process ID pid is to be sent a signal if
83 the user chooses to quit.
84
85
86 -l lower Defines the lower limit of the range as lower. Default is
87 the machine's largest negative long.
88
89
90 -p prompt Defines the prompt message as prompt.
91
92
93 -Q Specifies that quit will not be allowed as a valid
94 response.
95
96
97 -s signal Specifies that the process ID pid defined with the -k
98 option is to be sent signal signal when quit is chosen.
99 If no signal is specified, SIGTERM is used.
100
101
102 -u upper Defines the upper limit of the range as upper. Default is
103 the machine's largest positive long.
104
105
106 -W width Specifies that prompt, help and error messages will be
107 formatted to a line length of width.
108
109
111 The following operand is supported:
112
113 input Input to be verified against upper and lower limits and base.
114
115
117 Example 1 Default base 10 prompt
118
119
120 The default base 10 prompt for ckrange is:
121
122
123 example% ckrange
124 Enter an integer between lower_bound and
125 upper_bound [lower_bound−upper_bound,?,q]:
126
127
128
129 Example 2 Default base 10 error message
130
131
132 The default base 10 error message is:
133
134
135 example% /usr/sadm/bin/errange
136 ERROR: Please enter an integer between lower_bound \
137 and upper_bound.
138
139
140
141 Example 3 Default base 10 help message
142
143
144 The default base 10 help message is:
145
146
147 example% /usr/sadm/bin/helprange
148 Please enter an integer between lower_bound and upper_bound.
149
150
151
152 Example 4 Changing messages for a base other than 10
153
154
155 The messages are changed from ``integer'' to ``base base integer'' if
156 the base is set to a number other than 10. For example,
157
158
159 example% /usr/sadm/bin/helprange -b 36
160
161
162
163 Example 5 Using the quit option
164
165
166 When the quit option is chosen (and allowed), q is returned along with
167 the return code 3. Quit input gets a trailing newline.
168
169
170 Example 6 Using the valrange module
171
172
173 The valrange module will produce a usage message on stderr. It returns
174 0 for success and non-zero for failure.
175
176
177 example% /usr/sadm/bin/valrange
178 usage: valrange [-l lower] [-u upper] [-b base] input
179
180
181
183 The following exit values are returned:
184
185 0 Successful execution.
186
187
188 1 EOF on input, or negative width on -W option, or usage error.
189
190
191 2 Usage error.
192
193
194 3 User termination (quit).
195
196
198 See attributes(5) for descriptions of the following attributes:
199
200
201
202
203 ┌─────────────────────────────┬─────────────────────────────┐
204 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
205 ├─────────────────────────────┼─────────────────────────────┤
206 │Availability │SUNWcsu │
207 └─────────────────────────────┴─────────────────────────────┘
208
210 Intro(1), getopt(1), strtol(3C), attributes(5), signal.h(3HEAD)
211
212
213
214SunOS 5.11 4 Nov 2005 ckrange(1)