<s>
getopts	B-Library
is	O
a	O
built-in	O
Unix	B-Application
shell	I-Application
command	B-Application
for	O
parsing	O
command-line	O
arguments	O
.	O
</s>
<s>
It	O
is	O
designed	O
to	O
process	O
command	B-Application
line	O
arguments	O
that	O
follow	O
the	O
POSIX	O
Utility	O
Syntax	O
Guidelines	O
,	O
based	O
on	O
the	O
C	O
interface	O
of	O
getopt	B-Library
.	O
</s>
<s>
The	O
predecessor	O
to	O
was	O
the	O
external	O
program	O
by	O
Unix	B-Application
System	I-Application
Laboratories	O
.	O
</s>
<s>
getopts	B-Library
was	O
first	O
introduced	O
in	O
1986	O
in	O
the	B-Device
Bourne	I-Device
shell	I-Device
shipped	O
with	O
Unix	B-Application
SVR3	O
.	O
</s>
<s>
Earlier	O
versions	O
of	O
the	B-Device
Bourne	I-Device
shell	I-Device
did	O
not	O
have	O
getopts	B-Library
.	O
</s>
<s>
In	O
1995	O
,	O
getopts	B-Library
was	O
included	O
in	O
the	O
Single	O
UNIX	B-Application
Specification	O
version	O
1	O
/	O
X/Open	O
Portability	O
Guidelines	O
Issue	O
4	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
getopts	B-Library
is	O
now	O
available	O
in	O
shells	O
including	O
the	B-Device
Bourne	I-Device
shell	I-Device
,	O
KornShell	B-Language
,	O
Almquist	B-Operating_System
shell	I-Operating_System
,	O
Bash	B-Operating_System
and	O
Zsh	B-Application
.	O
</s>
<s>
The	O
command	B-Application
has	O
also	O
been	O
ported	O
to	O
the	O
IBM	B-Application
i	I-Application
operating	O
system	O
.	O
</s>
<s>
The	O
modern	O
usage	O
of	O
was	O
partially	O
revived	O
mainly	O
due	O
to	O
an	O
enhanced	O
implementation	O
in	O
util-linux	B-Application
.	O
</s>
<s>
The	O
usage	O
synopsis	O
of	O
getopt	B-Library
and	O
getopts	B-Library
is	O
similar	O
to	O
its	O
C	O
sibling	O
:	O
</s>
<s>
The	O
parameters	O
part	O
simply	O
accepts	O
whatever	O
one	O
wants	O
getopt	B-Library
to	O
parse	O
.	O
</s>
<s>
This	O
value	O
exists	O
in	O
getopts	B-Library
but	O
is	O
rarely	O
used	O
,	O
since	O
it	O
can	O
just	O
access	O
the	O
shell	O
's	O
parameters	O
.	O
</s>
<s>
The	O
varname	O
part	O
of	O
getopts	B-Library
names	O
a	O
shell	O
variable	O
to	O
store	O
the	O
option	O
parsed	O
into	O
.	O
</s>
<s>
getopt	B-Library
simply	O
returns	O
a	O
flat	O
string	O
containing	O
whitespace-separated	O
tokens	O
representing	O
the	O
"	O
normalized	O
"	O
argument	O
.	O
</s>
<s>
getopts	B-Library
is	O
meant	O
to	O
be	O
repeatedly	O
called	O
like	O
the	O
C	O
getopt	B-Library
.	O
</s>
<s>
As	O
a	O
result	O
,	O
this	O
new	O
feature	O
was	O
also	O
available	O
in	O
the	O
built-in	O
command	B-Application
getopts	B-Library
of	O
the	B-Device
Bourne	I-Device
Shell	I-Device
.	O
</s>
<s>
KornShell	B-Language
and	O
Zsh	B-Application
both	O
have	O
an	O
extension	O
for	O
long	O
arguments	O
.	O
</s>
<s>
The	O
former	O
is	O
defined	O
as	O
in	O
Solaris	O
,	O
while	O
the	O
latter	O
is	O
implemented	O
via	O
a	O
separate	O
command	B-Application
.	O
</s>
<s>
KornShell	B-Language
additionally	O
implements	O
optstring	O
extensions	O
for	O
options	O
beginning	O
with	O
instead	O
of	O
.	O
</s>
<s>
An	O
alternative	O
to	O
getopts	B-Library
is	O
the	O
Linux	O
enhanced	O
version	O
of	O
getopt	B-Library
,	O
the	O
external	O
command	B-Application
line	O
program	O
.	O
</s>
<s>
The	O
Linux	O
enhanced	O
version	O
of	O
getopt	B-Library
has	O
the	O
extra	O
safety	O
of	O
getopts	B-Library
plus	O
more	O
advanced	O
features	O
.	O
</s>
<s>
command	B-Application
operand1	O
operand2	O
-a	O
operand3	O
-b	O
is	O
permitted	O
by	O
the	O
Linux	O
enhanced	O
version	O
of	O
getopt	B-Library
but	O
does	O
not	O
work	O
with	O
getopts	B-Library
)	O
.	O
</s>
<s>
It	O
also	O
supports	O
escaping	O
metacharacters	O
for	O
shells	O
(	O
like	O
tcsh	B-Language
and	O
POSIX	O
sh	O
)	O
and	O
optional	O
arguments	O
.	O
</s>
<s>
Suppose	O
we	O
are	O
building	O
a	O
Wikipedia	O
downloader	O
in	O
bash	B-Operating_System
that	O
takes	O
three	O
options	O
and	O
zero	O
extra	O
arguments	O
:	O
</s>
<s>
The	O
old	O
getopt	B-Library
does	O
not	O
support	O
optional	O
arguments	O
:	O
</s>
<s>
Getopts	B-Library
give	O
the	O
script	O
the	O
look	O
and	O
feel	O
of	O
the	O
C	O
interface	O
,	O
although	O
in	O
POSIX	O
optional	O
arguments	O
are	O
still	O
absent	O
:	O
</s>
<s>
Linux	O
getopt	B-Library
escapes	O
its	O
output	O
and	O
an	O
"	O
eval	O
"	O
command	B-Application
is	O
needed	O
to	O
have	O
the	O
shell	O
interpret	O
it	O
.	O
</s>
