Hacker News new | past | comments | ask | show | jobs | submit login
getopt() but smaller (dotat.at)
7 points by fanf2 85 days ago | hide | past | favorite | 2 comments



I like NetBSD sh's nextopt <https://github.com/NetBSD/src/blob/23fcbd850aae17ef0843523f3...>. Since getopt's internal state can't be reset portably, most shells roll their own option parser.


Plan 9’s ARG(2) [0] macros are worth a look too. No dependencies at all, just plain macros, super lightweight and easy to use.

[0] https://9fans.github.io/plan9port/man/man3/arg.html




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: