Alfred M. Szmidt <[email protected]> ha escrit: > Thanks for the explanation. `--count 4' has never been valid with > argp.
Not at all, it is perfectly valid: g...@trurl:~$ ping --count 4 gnu.org PING gnu.org (199.232.41.10): 56 data bytes 64 bytes from 199.232.41.10: icmp_seq=0 ttl=47 time=176.773 ms 64 bytes from 199.232.41.10: icmp_seq=1 ttl=47 time=176.617 ms 64 bytes from 199.232.41.10: icmp_seq=2 ttl=47 time=176.241 ms 64 bytes from 199.232.41.10: icmp_seq=3 ttl=47 time=176.600 ms --- gnu.org ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max/stddev = 176.241/176.558/176.773/0.195 ms With long options, both `--opt=arg' and `--opt arg' are valid constructs. > As for the `-c 4' vs. `-c4' case, since we already use short-options > with optional arguments, the behaviour is already weird. Well, I'm not saying it's weird. Getopt makes its best to make it deterministic at least. But the downside is that one must remember which option takes mandatory and which one takes optional arguments, to correctly use them. Of course, we do use optional arguments when it is reasonable and does not harm compatibility. But in this particular case I have strong doubts: > In other words, users already must think about if they are using a > short option with an optional argument, or not so they cannot depend on this > behaviour. Users must always think first, that's a good rule :^) That's not a problem. The problem with `-c', as I see it, is that we are changing the behavior of a traditional option that was in ping from the days of its inception and many people had already made their habits of using it. Often these habits include separating the option argument by a space, because it improves readability. As a side note, at least one GNU manual encourages users to use this style of passing option arguments: it is the GNU tar manual. I am quite sure, many people use ping in their scripts this way, that is with `-c' and its argument separated. The proposed change will break those scripts. That is the most important reason that speaks against this change. Instead of changing the `-c' behaviour we can simply introduce a new option that will cause ping to stop after the default number of packets. FWIW, the `-C' letter is still unused in ping, so we can use it for that purpose. This will make for a good mnemonics. The corresponding long option might be more verbose, say `--default-count'. What do you think? Regards, Sergey
