Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Is this a bug, doc error, or misunderstanding?



From the zshexpn man page under 'Parameter Expansion Flags' section:

   n      Sort decimal integers numerically; if the first  differing  charac-
          ters  of  two  test  strings  are  not  digits, sorting is lexical.
          Integers with more initial zeroes  are  sorted  before  those  with
          fewer  or none.  Hence the array ‘foo1 foo02 foo2 foo3 foo20 foo23’
          is sorted into the order shown.  May be combined with ‘i’ or ‘O’.

So that tells me that as two elements are being compared, and the sort hits the
first occurrence of two differing characters, AND those characters are not
digits, sort the entries lexiographically.

$ VAR=(ZHOST40 HOST+ host04 host4 host36)

I would expect this, using the (n) expansion flag, to sort to:
HOST+ ZHOST40 host04 host4 host36

This is because when comparing 'ZHOST40' and 'host04', 'Z' comes before 'h'
lexiographically. However, this is not what we get...

$ echo ${(n)VAR}
HOST+ host04 host4 host36 ZHOST40

It appears as if the (n) flag in this case applied an implicit case-insensitive
flag (i), which is not what I wanted.

Is this a bug in the (n) expansion flag, an erroneous explanation in the man page,
or just something fundamental thing I'm not getting?

Thanks!

P.S. Zsh version 4.3.10





Messages sorted by: Reverse Date, Date, Thread, Author