bug-coreutils
[Top][All Lists]
Advanced

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

Re: sort does not use tab as delimiter


From: DI Oliver Maurhart
Subject: Re: sort does not use tab as delimiter
Date: Sun, 10 Dec 2006 12:15:31 +0100
User-agent: Thunderbird 1.5.0.8 (X11/20061127)

Hi,

Yes, it does, but this "feature" is pain ass to enter on a bash-shell:

1. It is bogus. Because you need to write a bash-script to actually have
a tab between the two apostrophes. You simply can't type that in
directly on a terminal. This is the very *only* way AFAIK, or do missing
something?

2. Relying to actually get the real withespace char instead of a literal
conceptionaly holding it, is good reason for headache. Ever heard that
some editors (actually most modern ones vim, emacs, kate, ...) are
capable of replacing tabs to spaces while typing? Since having spaces
instead of tabs is considered good programming style (See, actually the
code of sort.c I spotted *is* ugly ... and old fashioned as well.
"getopt()"? Where's argp?). So inserting a tab in sort -t '    ' will
not give you a tab but rather 4 spaces (or whatever width you stated).
And there's little chance to detect that, for both visually look the
same and you've entered a tab at the first place, didn't you?

3. Is there any good reason, why sort does not use very common whitspace
symbols like many other do? E.g. printf (of the GNU shell utils)? Are
all of them not portable, because they do use something "wired" like \t
for tab?

So, I wrote my comments and code examples in my previous mail relying on
shell commands directly typed on a console. Noted that leading '$' on my
lines?

Your answer is not correct, since you can't type that in on a console.
Ok, yes, you can do that by studying how the bash handles readline, by
getting some vim-enabled-bash, etc. There's always a way around.
However, I'm talking about having a very plain stupid bash installed in
nearly any Linux, *BSD, What-so-ever-NIX around. Typing tab usually
gives you command-completion, doesn't it? Without any other additional
gadgets or tools added.


Doing this like this:

$ sort -t printf \t -k 2 FILE
$ sort -t `printf \t` -k 2 FILE
$ sort -t "`printf \t`" -k 2 FILE

a) is a hack ... because sort can't handle things by itself directly
b) doesn't work in any case either

$ eval `printf "sort -t '\t' -k 2 FILE"`

... is sure the first prize of geek'ness, when asked the very trivial
question "How do I sort the 2nd col with tabs on a shell?" in the
forums, ha? However, it doesn't work as well!

But according to your statement the correct way is:

$ echo "#! /bin/sh" > mysort && printf "sort -t '\t' -k 2 SORT" >>
mysort &&  chmod u+x mysort && ./mysort

Oh my gosh!! If the previous was the first prize, this sure is the nobel
prize, ha? ;-)

Having a
$ sort -t "\t" -k 2 FILE
instead is sure pretty boring ...


So, sorry Mr. Eggert, but your answer is ... well ... unsatisfactory. In
many ways.


Fellin' disappointed now, though.


kR

Oliver


PS: Please, don't take my comments tooo serious or personal ... ;-)


Paul Eggert wrote:
> DI Oliver Maurhart <address@hidden> writes:
> 
>> I've noticed that sort doesn't use the tab as delimiter when
>> provided by the '-t' option.
> 
> Actually it does, if you invoke it this way:
> 
>      sort -t '        ' -k 2 FILE
> 
> Note that there is a tab between the two apostrophes.
> 
> It might be nice for 'sort' to support a more extended syntax, but
> in the meantime the above technique will work without changing
> 'sort' (also, it's portable to other platforms).
> 

-- 
/**
 * This is my signature
 *
 * @return      all may account data (if you need it)
 */
CAddress CEMailSignature::getMyAddress() const {

   QString sTitle      = "Dipl.Ing.";
   QString sName       = "Oliver Maurhart";
   QString sProfession = "Software Development";

   QString sStreet     = "Duernfeld 3";
   QString sCity       = "9064 Pischeldorf";
   QString sState      = "AUSTRIA";

   // Telefon as hex: 0x3EAB83D3B45
   // But as dec seems more convenient, doesn't it?
   QString sTelefon    = "+43 / (0)664 / 825 12 05";

   // should return: "address@hidden"
   QString sEMail      = getCurrentMail().getFrom();

   // Chat?
   try {
      ICQ::openChat(194511669);
      MSN::openChat("address@hidden");
   }
   catch (IM::IamOfflineException& cException) {
      fprintf(stdout, "Sorry, but %s\n", cException.getReason());
   }

   // normaly I use a single line here ...
   return CAddress(sName,
      sProfession,
      sStreet,
      sCity,
      sState,
      sTelefon,
      sEMail);
}

Attachment: oliver.maurhart.vcf
Description: Vcard

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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