# Getopt != getopts

**URL:** <https://discuss.kakoune.com/t/getopt-getopts/388>\
**Category:** Off Topic\
**Created:** [March 21, 2019, 3:37pm UTC](https://discuss.kakoune.com/t/getopt-getopts/388 "2019-03-21T15:37:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Delapouite](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/delapouite/32/10_2.png) [@Delapouite](https://discuss.kakoune.com/u/Delapouite)\
**Post date:** [March 21, 2019, 3:37pm UTC](https://discuss.kakoune.com/t/getopt-getopts/388/1 "2019-03-21T15:37:23Z")

</div>

Hello

Here’s another ‘aha moment’ I got recently. I wanted to share it with you since writing kak scripts often implies to mess with shell/tools details.

`getopt` and `getopts` (notice the ending `s`) are closely related beasts, but as usual have a few discrepancies! I never really pay attention that they were different stuffs and I’ll let the Wikipedia articles explain them better than I could:

> **[getopt](https://en.wikipedia.org/wiki/Getopt)**
>
> Getopt is a C library function used to parse command-line options of the Unix/POSIX style. It is a part of the POSIX specification, and is universal to Unix-like systems.
> It is also the name of a Unix program for parsing command line arguments in shell scripts.
> A long-standing issue with command line programs was how to specify options; early programs used many ways of doing so, including single character options (-a), multiple options specified together (-abc is equivalent to -a -b -c), multich...

> **[getopts](https://en.wikipedia.org/wiki/Getopts)**
>
> getopts is a built-in Unix shell command for parsing command-line arguments. It is designed to process command line arguments that follow the POSIX Utility Syntax Guidelines, based on the C interface of getopt.
> The predecessor to getopts was the external program getopt by Unix System Laboratories.
> The original getopt had several problems: it could not handle whitespace or shell metacharacters in arguments, and there was no ability to disable the output of error messages.
> getopts was first intr...

---

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [March 23, 2019, 2:24am UTC](https://discuss.kakoune.com/t/getopt-getopts/388/2 "2019-03-23T02:24:19Z")

</div>

Cliffsnotes some of the difference you stumbled onto? (/lazy /packing\_for\_rome)
