Bug 34623

Summary: getopt_long: unintended change of error message breaks third party tests
Product: Sisyphus Reporter: Alexey Gladkov <legion>
Component: glibc-coreAssignee: placeholder <placeholder>
Status: ASSIGNED --- QA Contact: qa-sisyphus
Severity: normal    
Priority: P3 CC: glebfm, ldv, placeholder
Version: unstable   
Hardware: all   
OS: Linux   

Description Alexey Gladkov 2018-03-08 12:44:59 MSK
Current getopt_long from the glibc-2.27-alt1 output:

$ LANG=C getopt -a -n TEST -o 'a,b,c' -l 'caa:,cba:' -- -c='AAA' 
TEST: option '-c=AAA' is ambiguous; possibilities: '-caa' '-cba'

but before the output was:

$ LANG=C getopt -a -n TEST -o 'a,b,c' -l 'caa:,cba:' -- -c='AAA' 
TEST: option '-c=AAA' is ambiguous; possibilities: '--caa' '--cba'

Some tests in libshell and util-linux compare the output of getopt command to the reference output. These tests broke.

The new error output does not look correct because the variants are searched among the long options. Also the `-cba' is more like a shortened `-c -b -a'.

Do I have to correct tests for a new message everywhere?
Comment 1 Dmitry V. Levin 2018-03-08 16:35:51 MSK
The change of error output is a side effect of commit glibc-2.26~634:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=glibc-2.25.90-191-gaeacb9f

The commit message does not look as if the side effect was intended.
Comment 2 Alexey Gladkov 2018-03-08 16:50:30 MSK
Will the error message be fixed ?
Comment 3 Alexey Gladkov 2018-03-08 16:59:45 MSK
It was easy to miss that prefix variable does not always contain `--'.
It looks like glibc doesn't have enough tests for getopt_long. :))
Comment 4 Dmitry V. Levin 2018-03-08 17:52:55 MSK
Forwarded to https://sourceware.org/bugzilla/show_bug.cgi?id=22939