You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just got back to this. The error lies in getopt's different behavior of
arguments (one colon) and optional arguments (two colons). The latter is
used here and, just for the record, a non-POSIX extension initially
added as a GNU extension, later ported to other libcs.
The difference is well explained in OpenBSD's getopt(3):
It does not matter to getopt() if a following argument has
leading whitespace; except in the case where the argument is
optional, denoted with two colons, no leading whitespace is
permitted.
This is identical to the glibc behavior, but, unless I missed it in
their man page, does not explicitly states this.
Thus, getting back to the initially reported error, the following
version works:
./check_curl -H monitoring-plugins.org -S1.2+
HTTP OK: HTTP/1.1 301 Moved Permanently - 388 bytes in 0.104 second response time |time=0.104171s;;;0.000000;10.000000 size=388B;;;0;
One might close this, as it works as intended.
However, this results in an atypical usage, at least in my opinion. This
can be seen in the Icinga 2 ITL issue[0].
Btw, the merged version does not work as expected. The "(-S w/ value)"
case sets a value which will get lost.
./check_curl -vv -H monitoring-plugins.org -I 130.133.8.40 -S 1.2+
* Set SSL/TLS version to 0
After the 'S' getopt_long case, the next iteration results in 'c == -1'.
Thus, I would suggest either documenting this or changing the parsing
logic.
[0]: Icinga/icinga2#9205 (comment)
Hopefully this output explains it better than I could do with words:
The text was updated successfully, but these errors were encountered: