git: ls(1): Alter time portion of "long format"

John Marino marino at crater.dragonflybsd.org
Fri Nov 20 05:36:30 PST 2015


commit 0b35d94f4cab7ac814260ce14ceb39c47e7f958b
Author: John Marino <draco at marino.st>
Date:   Fri Nov 20 13:49:26 2015 +0100

    ls(1): Alter time portion of "long format"
    
    One side effect of moving to the CLDR standard for locale definitions
    is that abreviated months are no longer guaranteed to align.  We altered
    the definitions for CJK to ensure this, but we do not want to manually
    adjust every locale.
    
    The most obvious manifestation is seen with ls(1) using the long format
    (-l option).  Not only is the month abbreviation no longer guaranteed to
    be 3 characters wide, it's not even guaranteed to be a uniform width.  As
    a result, the file listing may no longer line up, as seen with French:
    
      ironwolf# env LANG=fr_FR.UTF-8 ls -l | head
      drwxr-xr-x  2 root  wheel   512 26 mars  2015 ariadne
      drwxr-xr-x  2 root  wheel   512 26 mars  2015 artemis
      drwxr-xr-x  3 root  wheel   512  9 sept. 19:45 avida
      drwxr-xr-x  3 root  wheel   512  9 sept. 19:45 babel
      drwxr-xr-x  3 root  wheel   512 15 juin 20:38 bcftools
      drwxr-xr-x  2 root  wheel   512 20 sept. 11:27 biococoa
      drwxr-xr-x  2 root  wheel   512 26 mars  2015 biojava
      drwxr-xr-x  3 root  wheel   512 26 mars  2015 blat
      drwxr-xr-x  3 root  wheel   512  7 nov. 08:44 bwa
    
      ironwolf# env LANG=fr_FR.UTF-8 ls -lT | head
      drwxr-xr-x  2 root  wheel   512 26 mars 10:15:28 2015 ariadne
      drwxr-xr-x  2 root  wheel   512 26 mars 10:15:28 2015 artemis
      drwxr-xr-x  3 root  wheel   512  9 sept. 19:45:04 2015 avida
      drwxr-xr-x  3 root  wheel   512  9 sept. 19:45:04 2015 babel
      drwxr-xr-x  3 root  wheel   512 15 juin 20:38:55 2015 bcftools
      drwxr-xr-x  2 root  wheel   512 20 sept. 11:27:40 2015 biococoa
      drwxr-xr-x  2 root  wheel   512 26 mars 10:15:28 2015 biojava
      drwxr-xr-x  3 root  wheel   512 26 mars 10:15:28 2015 blat
      drwxr-xr-x  3 root  wheel   512  7 nov. 08:44:24 2015 bwa
    
    To address both issues (misalignment and differing widths as a function
    of locale), I've modified ls(1) to use valid forms of ISO 8601, an
    international standard for the representation of time.
    
    The default long format produces the last modified timestamp in the form
    of YYYYMMDDTHH (Year|Month|Day|T|Hour with no spaces).  This is known as
    the "basic" format which includes the optional "T" concatenator.  The
    result is the time is represented by a single column using 1-3 characters
    less than before.
    
      ironwolf# env LANG=fr_FR.UTF-8 ls -l | head
      drwxr-xr-x  2 root  wheel   512 20150326T10 ariadne
      drwxr-xr-x  2 root  wheel   512 20150326T10 artemis
      drwxr-xr-x  3 root  wheel   512 20150909T19 avida
      drwxr-xr-x  3 root  wheel   512 20150909T19 babel
      drwxr-xr-x  3 root  wheel   512 20150615T20 bcftools
      drwxr-xr-x  2 root  wheel   512 20150920T11 biococoa
      drwxr-xr-x  2 root  wheel   512 20150326T10 biojava
      drwxr-xr-x  3 root  wheel   512 20150326T10 blat
      drwxr-xr-x  3 root  wheel   512 20151107T08 bwa
    
    The -T option uses the extended format of ISO 8601 without the T symbol,
    but with the minutes and seconds representation.  The result is two
    characters wider than the approach FreeBSD is taking to address the same
    issue (FreeBSD is padding the month section and expanding the field by
    two characters to accommodate 5-character wide month names).  The output
    on DragonFly looks like this:
    
      ironwolf# env LANG=fr_FR.UTF-8 ls -lT | head
      drwxr-xr-x  2 root  wheel   512 2015-03-26 10:15:28 ariadne
      drwxr-xr-x  2 root  wheel   512 2015-03-26 10:15:28 artemis
      drwxr-xr-x  3 root  wheel   512 2015-09-09 19:45:04 avida
      drwxr-xr-x  3 root  wheel   512 2015-09-09 19:45:04 babel
      drwxr-xr-x  3 root  wheel   512 2015-06-15 20:38:55 bcftools
      drwxr-xr-x  2 root  wheel   512 2015-09-20 11:27:40 biococoa
      drwxr-xr-x  2 root  wheel   512 2015-03-26 10:15:28 biojava
      drwxr-xr-x  3 root  wheel   512 2015-03-26 10:15:28 blat
      drwxr-xr-x  3 root  wheel   512 2015-11-07 08:44:24 bwa
    
    The long format no longer changes if the last modified time is within six
    months (future or past), thus file times are more quickly comparable with
    a quick visual scan versus switching between year and hours:seconds.
    
    Reported by:	bapt at FreeBSD.org

Summary of changes:
 bin/ls/ls.1    | 16 ++++++----------
 bin/ls/print.c | 16 ++++------------
 2 files changed, 10 insertions(+), 22 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/0b35d94f4cab7ac814260ce14ceb39c47e7f958b


-- 
DragonFly BSD source repository



More information about the Commits mailing list