coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] join: add support \t as a field delimiter


From: Eric Blake
Subject: Re: [PATCH] join: add support \t as a field delimiter
Date: Mon, 18 Nov 2013 09:26:01 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 11/18/2013 09:10 AM, Jongyeol Choi wrote:
>>From a9c435ded74ee7d274e5ae2a0dd239ddb8255264 Mon Sep 17 00:00:00 2001
> From: Jongyeol Choi <address@hidden>
> Date: Tue, 19 Nov 2013 00:29:55 +0900
> Subject: [PATCH] join: add support \t as a field delimiter
> 
> * src/join.c (main): In the getopt_long loop, handle the \t character.
> * tests/misc/join.pl: Add a test case for \t.
> ---
>  src/join.c         | 2 ++
>  tests/misc/join.pl | 2 ++
>  2 files changed, 4 insertions(+)

Why is this necessary?

> 
> diff --git a/src/join.c b/src/join.c
> index 1da618d..2f6c6ff 100644
> --- a/src/join.c
> +++ b/src/join.c
> @@ -1104,6 +1104,8 @@ main (int argc, char **argv)
>                {
>                  if (STREQ (optarg, "\\0"))
>                    newtab = '\0';

There is no way to write a NUL byte as a shell argument passed to an
argv.  But it is quite easy to write a literal tab, so I'm not sure we
need the bloat for \t (and if we DO bloat for \t, we should also support
\f, \n, \r, ...)

That is, why not just write:

tab="   " # use ctrl-v;tab if that helps you write a literal tab
join -t "$tab" ...

or even use this bash extension (the next version of POSIX plans to
standardize it, but it's not universal yet):

join -t $'\t'

-- 
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

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