Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11826

Re: Paste with null delimiter

From Eric Blake <eblake@redhat.com>
Newsgroups gnu.bash.bug
Subject Re: Paste with null delimiter
Date 2015-11-03 13:32 -0700
Organization Red Hat, Inc.
Message-ID <mailman.1616.1446582779.7904.bug-bash@gnu.org> (permalink)
References <3a207f09-fc2b-4a2e-a6e5-1d33c7479849@googlegroups.com> <CANaoh6+UXA40cdevY2373Ubq=J1vSYgw1wV_8e9HMvLmWkOJQA@mail.gmail.com> <CAJ=pi6kdLLxkWaUeGvyrCLc+07d_U-ydPL+7iQvrsZfPHpyajw@mail.gmail.com> <CANaoh6Lfbgtk8M687Bq7Pz9vb0TzO1vewXGS4OzWrt16H_u7yQ@mail.gmail.com>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 11/03/2015 01:09 PM, Dennis Williamson wrote:
> On Nov 3, 2015 12:47 PM, "Julio C. Neves" <julio.neves@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

Back to gnu.bash.bug | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Paste with null delimiter julio.neves@gmail.com - 2015-11-03 08:29 -0800
  Re: Paste with null delimiter Eric Blake <eblake@redhat.com> - 2015-11-03 10:41 -0700
  Re: Paste with null delimiter Andreas Schwab <schwab@linux-m68k.org> - 2015-11-03 18:47 +0100
  Re: Paste with null delimiter Eric Blake <eblake@redhat.com> - 2015-11-03 13:32 -0700
  Re: Paste with null delimiter Eric Blake <eblake@redhat.com> - 2015-11-03 13:43 -0700
  Re: Paste with null delimiter Eric Blake <eblake@redhat.com> - 2015-11-03 13:52 -0700
  Re: Paste with null delimiter Andreas Schwab <schwab@linux-m68k.org> - 2015-11-03 22:57 +0100
  Re: Paste with null delimiter Stephane Chazelas <stephane.chazelas@gmail.com> - 2015-11-04 15:44 +0000

csiph-web