sort problems

liberte at uiucdcs.UUCP liberte at uiucdcs.UUCP
Sat Jan 26 04:15:00 AEST 1985


On our 4.2bsd, the effect of the -b flag was reversed.  That is, instead
of ignoring leading blanks, it ignores trailing blanks.  

Why?  Possibly because the default action (in the 4.1 distribution) is
screwy.  Instead of specifying field numbers, you specify how many fields to
skip, and then count the leading spaces as part of the next field after
those skipped.

Possibly because the documentation (7th edition) may be misleading.
"The notation +pos1 -pos2 restricts a sort key to a field beginning at pos1
and ending just BEFORE pos2."  Later it says that "...fields are nonempty
nonblank strings separated by blanks."  In any event, it is confusing.
While the b flag on pos1 ignores leading blanks, what is the intended effect
of the b flag on pos2?  The actual effect is to INCLUDE the blanks before
pos2 in the sort key.  So watch out for the global -b.

Partly because of these problems, and partly because I was confused when I
did it, I changed our version of sort to always, really ignore blanks unless
a tab char is specified.  I should have also had the b flag reverse this
effect.  This is what most people want.  But I now think it was a mistake to
change sort at all, even by Berkeley.  There is value in the old way.

Daniel LaLiberte
ihnp4!uiucdcs!liberte
liberte at uiucdcs.Uiuc.ARPA
U of Illinois, Urbana-Champaign, 
Dept of Computer Science
(217) 333-8426



More information about the Comp.unix mailing list