Message271395
On Tue, Jul 26, 2016 at 03:27:29PM +0000, R. David Murray wrote:
[...]
> getopt is explicitly emulating the C getopt
There are lots of differences between the C getopt and the Python
version, and the Python version is described as offering an API
"designed to be familiar" to uses of the C version, not to emulate all
the idiosyncrasies of the C version. For instance, the Python version
raises an exception on errors, rather than returning -1; the C version
requires argc ("argument count"), but the Python version doesn't.
But most critically, the C version DOES strip whitespace from long
arguments. On my Centos box, it only strips *trailing* spaces, not
leading spaces, but it does strip them. So if your argument is that we
must do what the C getopt does, then we must likewise at least strip
trailing spaces.
Attached is a demo, adapted from the code given by `man 3 getopt`.
[steve@ando ~]$ gcc getopdemo.c
[steve@ando ~]$ ./a.out "-- spam" 1 --eggs 2 "-- cheese" 3
option spam with arg 1
option eggs with arg 2
option cheese with arg 3
If Serhiy is going to insist that getopt.py must follow the C getopt
precisely, then the failure to strip trailing spaces is certainly a bug. |
File name |
Uploaded |
getopdemo.c
|
steven.daprano,
2016-07-26.17:06:27
|
|
Date |
User |
Action |
Args |
2016-07-26 17:06:27 | steven.daprano | set | recipients:
+ steven.daprano, r.david.murray, berker.peksag, serhiy.storchaka |
2016-07-26 17:06:27 | steven.daprano | link | issue27619 messages |
2016-07-26 17:06:27 | steven.daprano | create | |
|