bug-textutils
[Top][All Lists]
Advanced

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

Re: Sort uses -d by default?


From: Bob Proulx
Subject: Re: Sort uses -d by default?
Date: Mon, 19 Mar 2001 23:55:58 -0700

> I am either going mad, or sort in Textutils 2.0e works differently than
> sort in Textutils 2.0a.
> 
> the sort in 2.0e seems to default with the -d flag on, and i cannot find
> a way to get around this.  even -i does not override this setting.  is
> there any way around this?

Hmm...  At first glance I don't think this is exactly your problem.
But so many sort problems are related to the environment which tells
sort to use locale data that I have to respond with this answer first.
Give this a try and see if that solves your problem.

Jim has previously answered these reports with the following mail.
Note that some vendors set those language variables for you without
you being aware of them.

Bob


========================================================================

Jim Meyering writes:

You are using the version of sort that comes with textutils-2.0
or newer and have reported a problem whereby it is sorting in
some non-ASCII order.

That is due not to a bug in sort, but to the fact that you have
set environment variables that direct sort to use improper locale-
specific tables (you or your vendor have probably set environment
variables like LANG, LC_ALL, or LANGUAGE to en_US).

Unset them, and then set LC_ALL to POSIX

  # If you use bash or some other Bourne-based shell,
  export LC_ALL=POSIX

  # If you use a C-shell,
  setenv LC_ALL POSIX

and sort will then work the way you expect.
-----------

BTW, in recent textutils test releases, sort --help output
includes this:

  *** WARNING ***
  This version of sort honors the locale settings in your environment.
  For example, if you set one of the LANG or LC_ALL environment variables
  to `en_US', then sort will work very differently than most people expect.
  If that's not what you want, then set LC_ALL to POSIX in your environment.

========================================================================

> I dunno, but somehow this looks like a bug to me.
> Does this look like a bug to you, or am I making some bad assumptions
> here...?
> 
> address@hidden SortBugs]$ cat /etc/issue
> 
> Red Hat Linux release 6.2 (Zoot)
> Kernel 2.2.14-5.0 on an i586
> 
> address@hidden SortBugs]$ 
> 
> Here are the files to sort:
> 
> address@hidden SortBugs]$ cat foo1
> 1-2-1-4-4
> 1-2-1-4-3
> 1-2-1-4-2
> 1-2-1-4-1
> 1-2-1-4
> address@hidden SortBugs]$ cat foo2
> 1-2-1-4-4:
> 1-2-1-4-3:
> 1-2-1-4-2:
> 1-2-1-4-1:
> 1-2-1-4:
> address@hidden SortBugs]$ cat foo3
> 1-2-1-4-4:a
> 1-2-1-4-3:b
> 1-2-1-4-2:c
> 1-2-1-4-1:d
> 1-2-1-4:e
> address@hidden SortBugs]$ 
> 
> 
> Now, lets sort these files using ":" as the key delimeter
> 
> TEST #1
> address@hidden SortBugs]$ sort -d -t: -k1 foo1
> 1-2-1-4
> 1-2-1-4-1
> 1-2-1-4-2
> 1-2-1-4-3
> 1-2-1-4-4
> 
> Yeah, I expected this result, lets move on to the next...
> 
> TEST #2
> address@hidden SortBugs]$ sort -d -t: -k1 foo2
> 1-2-1-4:
> 1-2-1-4-1:
> 1-2-1-4-2:
> 1-2-1-4-3:
> 1-2-1-4-4:
> 
> Still lookin' good, next...
> 
> TEST #3
> address@hidden SortBugs]$ sort -d -t: -k1 foo3
> 1-2-1-4-1:d
> 1-2-1-4-2:c
> 1-2-1-4-3:b
> 1-2-1-4-4:a
> 1-2-1-4:e
> 
> Whoa!  Not what I expected!  Lets look at foo2 again, without
> alphanumeric key restriction...
> 
> TEST #4
> address@hidden SortBugs]$ sort  -t: -k1 foo2
> 1-2-1-4-1:
> 1-2-1-4-2:
> 1-2-1-4-3:
> 1-2-1-4-4:
> 1-2-1-4:
> 
> Well, OK, I guess so, but ":" is the delimeter, so why is it being
> considered in the sort?  
> 
> Now another sanity check on key position "2"
> 
> TEST #5
> address@hidden SortBugs]$ sort -d -t: -k2 foo3
> 1-2-1-4-4:a
> 1-2-1-4-3:b
> 1-2-1-4-2:c
> 1-2-1-4-1:d
> 1-2-1-4:e
> address@hidden SortBugs]$ 
> 
> Looks OK to me...
> 
> 
> 
> QUESTION:  Can you explain what is happening in TEST #3 and TEST #4?  Is
> this expected behavior, or a bug?
> 
> tnx,
> 
> Harry
> 
> 
> -- 
> Harry Rarig                        _/  _/   _/    _/_/_/  _/_/_/  _/  _/
> Tellium Inc.                      _/_/_/ _/_/_/  _/_/_/  _/_/_/    _/
> 732 923-4249 Voice               _/  _/ _/  _/ _/   _/ _/   _/    _/
> 732 923-9804 Fax                ___________________________________/
> 
> System Test  ====>>  "We break the things that make communications work"
> 
> _______________________________________________
> Bug-textutils mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-textutils



reply via email to

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