значение optind не будет сбрасываться при каждом вызове getopt [закрыто]

Linux Mint 18.3 Sylvia также основана на Xenial.

Я использовал Secure APT согласно веб-сайту Cran .

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9

Затем добавьте репозиторий, как ответил boris -quiroz .

-1
26.01.2020, 15:29
1 ответ

От мужчинаgetopt:

Notes

A program that scans multiple argument vectors, or rescans the same vector more than once, and wants to make use of GNU extensions such as '+' and '-' at the start of optstring, or changes the value of POSIXLY_CORRECT between scans, must reinitialize getopt() by resetting optind to 0, rather than the traditional value of 1. (Resetting to 0 forces the invocation of an internal initialization routine that rechecks POSIXLY_CORRECT and checks for GNU extensions in optstring.)

Таким образом, простого optind = 0;между вызовами getopt()должно быть достаточно.

0
28.01.2020, 05:11

Теги

Похожие вопросы