There are some issues with the current getopt_long implementation, namely:
It incorrectly treats an argument following a short optional option as a value for that option (eg. in sed -i '<pattern>' optarg is incorrectly set to <pattern> when parsing -i).
It doesn't move the non-arguments to the end of the argv array like it is supposed to do and set optind to the starting index of that contiguous sequence of non-options in case it reaches the end of argv.
There are some issues with the current getopt_long implementation, namely:
sed -i '<pattern>'
optarg is incorrectly set to<pattern>
when parsing-i
).optind
to the starting index of that contiguous sequence of non-options in case it reaches the end ofargv
.