aboutsummaryrefslogtreecommitdiff
path: root/libbb/getopt32.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-24 21:54:44 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-24 21:54:44 +0000
commitd031ffa623203b1dc756a1e02e06f261fdc30872 (patch)
tree26f4426eba02d3b7f22da62ef3af151a89c99e3f /libbb/getopt32.c
parentb833ca9d2d705943bb980c7a705aa3f07c7b5618 (diff)
downloadbusybox-w32-d031ffa623203b1dc756a1e02e06f261fdc30872.tar.gz
busybox-w32-d031ffa623203b1dc756a1e02e06f261fdc30872.tar.bz2
busybox-w32-d031ffa623203b1dc756a1e02e06f261fdc30872.zip
tar: sanitize option handling
Diffstat (limited to 'libbb/getopt32.c')
-rw-r--r--libbb/getopt32.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index f442933a3..dddf8121a 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -147,6 +147,40 @@ const char *opt_complementary
147 147
148Special characters: 148Special characters:
149 149
150 "-" A dash as the first char in a opt_complementary group forces
151 all arguments to be treated as options, even if they have
152 no leading dashes. Next char in this case can't be a digit (0-9),
153 use ':' or end of line. For example:
154
155 opt_complementary = "-:w-x:x-w";
156 getopt32(argc, argv, "wx");
157
158 Allows any arguments to be given without a dash (./program w x)
159 as well as with a dash (./program -x).
160
161 "--" A double dash at the beginning of opt_complementary means the
162 argv[1] string should always be treated as options, even if it isn't
163 prefixed with a "-". This is useful for special syntax in applets
164 such as "ar" and "tar":
165 tar xvf foo.tar
166
167 "-N" A dash as the first char in a opt_complementary group followed
168 by a single digit (0-9) means that at least N non-option
169 arguments must be present on the command line
170
171 "=N" An equal sign as the first char in a opt_complementary group followed
172 by a single digit (0-9) means that exactly N non-option
173 arguments must be present on the command line
174
175 "?N" A "?" as the first char in a opt_complementary group followed
176 by a single digit (0-9) means that at most N arguments must be present
177 on the command line.
178
179 "V-" An option with dash before colon or end-of-line results in
180 bb_show_usage being called if this option is encountered.
181 This is typically used to implement "print verbose usage message
182 and exit" option.
183
150 "-" A dash between two options causes the second of the two 184 "-" A dash between two options causes the second of the two
151 to be unset (and ignored) if it is given on the command line. 185 to be unset (and ignored) if it is given on the command line.
152 186
@@ -173,30 +207,6 @@ Special characters:
173 if (opt & 4) 207 if (opt & 4)
174 printf("Detected odd -x usage\n"); 208 printf("Detected odd -x usage\n");
175 209
176 "-" A dash as the first char in a opt_complementary group forces
177 all arguments to be treated as options, even if they have
178 no leading dashes. Next char in this case can't be a digit (0-9),
179 use ':' or end of line. For example:
180
181 opt_complementary = "-:w-x:x-w";
182 getopt32(argc, argv, "wx");
183
184 Allows any arguments to be given without a dash (./program w x)
185 as well as with a dash (./program -x).
186
187 "-N" A dash as the first char in a opt_complementary group followed
188 by a single digit (0-9) means that at least N non-option
189 arguments must be present on the command line
190
191 "=N" An equal sign as the first char in a opt_complementary group followed
192 by a single digit (0-9) means that exactly N non-option
193 arguments must be present on the command line
194
195 "V-" An option with dash before colon or end-of-line results in
196 bb_show_usage being called if this option is encountered.
197 This is typically used to implement "print verbose usage message
198 and exit" option.
199
200 "--" A double dash between two options, or between an option and a group 210 "--" A double dash between two options, or between an option and a group
201 of options, means that they are mutually exclusive. Unlike 211 of options, means that they are mutually exclusive. Unlike
202 the "-" case above, an error will be forced if the options 212 the "-" case above, an error will be forced if the options
@@ -221,10 +231,6 @@ Special characters:
221 if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage 231 if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage
222 and exit instead. Next char after '?' can't be a digit. 232 and exit instead. Next char after '?' can't be a digit.
223 233
224 "?N" A "?" as the first char in a opt_complementary group followed
225 by a single digit (0-9) means that at most N arguments must be present
226 on the command line.
227
228 "::" A double colon after a char in opt_complementary means that the 234 "::" A double colon after a char in opt_complementary means that the
229 option can occur multiple times. Each occurrence will be saved as 235 option can occur multiple times. Each occurrence will be saved as
230 a llist_t element instead of char*. 236 a llist_t element instead of char*.
@@ -245,12 +251,6 @@ Special characters:
245 root:x:0:0:root:/root:/bin/bash 251 root:x:0:0:root:/root:/bin/bash
246 user:x:500:500::/home/user:/bin/bash 252 user:x:500:500::/home/user:/bin/bash
247 253
248 "--" A double dash at the beginning of opt_complementary means the
249 argv[1] string should always be treated as options, even if it isn't
250 prefixed with a "-". This is useful for special syntax in applets
251 such as "ar" and "tar":
252 tar xvf foo.tar
253
254 "?" An "?" between an option and a group of options means that 254 "?" An "?" between an option and a group of options means that
255 at least one of them is required to occur if the first option 255 at least one of them is required to occur if the first option
256 occurs in preceding command line arguments. 256 occurs in preceding command line arguments.