[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] ping, --count=NUMBER

From: Sergey Poznyakoff
Subject: Re: [bug-inetutils] ping, --count=NUMBER
Date: Tue, 19 May 2009 16:37:35 +0300

Alfred M. Szmidt <address@hidden> ha escrit:

>       ping -c 4
>    which will break when -c is changed to accept optional argument.
> Eh, why would this break anything?

Because of the way GNU getopt implements optional arguments.  If an
option takes optional argument *and* that argument is given, it must
be specified the following way:

a) when used with short option, the argument must follow that option
immediately, without any intervening whitespace.
b) when used with long option, the argument must be separated from
the option word by exactly one equals sign.

In other words, if '-c' takes optional argument, then:

   ping -c4
   ping --count=4

means '-c' with the argument '4'.  On the contrast, this:

   ping -c 4
   ping --count 4

means '--count' *without* explicit argument plus a standalone
argument '4'.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]