On 11/03/2015 01:09 PM, Dennis Williamson wrote:
> On Nov 3, 2015 12:47 PM, "Julio C. Neves" <julio.ne...@gmail.com> wrote:
>>
>> Thanks Dennis,
>> I know that you are rigth, but "paste -d"" odd even" and "paste -d "" odd
> even" are not the same? The diference is only a space between the option
> and its parameter.

They are indeed not the same.  In long option form, you have:

paste -d "" odd even
 ==
paste --delimiters="" odd even
 ==
paste --delimiters= odd even
 ==
paste --delimiters "" odd even

while:

paste -d"" odd even
 ==
paste -d odd even
 ==
paste --delimiters=odd even
 ==
paste --delimiters odd even

Remember, the shell strips quotes before it hands arguments to paste.
Thus, paste is receiving, as argv, ["paste", "-d", "", "odd", "even"]
for the first group, and ["paste", "-d", "odd", "even"] for the second
group.

There is NO way for any program using getopt() or getopt_long() to know
if the user spelled '-d""' vs. '"-d"' vs. '-d', or any other myriad of
patterns where the quotes are stripped.  The ONLY way to pass an empty
string argument to a short option is to do it as a separate argument,
because the quotes are already stripped by the time argv is formed.
Thus, the space is essential.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to