summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2009-09-28 17:32:15 +0100
committerPádraig Brady <P@draigBrady.com>2010-07-01 13:12:52 +0100
commit8aa15b2be2bd2ab4b76d197a279abf8b9091680a (patch)
tree6a4d05b3b9d2c55875389f24dac5a4c032bca417
parent7336920dd07478b7bdae05ec599da4e2e66a94ff (diff)
downloadcoreutils-8aa15b2be2bd2ab4b76d197a279abf8b9091680a.tar.xz
ls: use the POSIX date style when the locale does not specify one
Previously we defaulted to "long-iso" format in locales without specific format translations, like the en_* locales for example. This reverts part of commit 6837183d, 08-11-2005, "ls ... acts like --time-style='posix-long-iso' if the locale settings are messed up" * src/ls.c (decode_switches): Only use the ISO format when specified. * NEWS: Mention the change in behavior. Reported by Daniel Qarras at http://bugzilla.redhat.com/525134
-rw-r--r--NEWS9
-rw-r--r--doc/coreutils.texi9
-rw-r--r--src/ls.c12
-rwxr-xr-xtests/misc/ls-time20
4 files changed, 35 insertions, 15 deletions
diff --git a/NEWS b/NEWS
index 3e170c501..2bacb7f0e 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,15 @@ GNU coreutils NEWS -*- outline -*-
** Changes in behavior
+ ls -l now uses the traditional three field time style rather than
+ the wider two field numeric ISO style, in locales where a style has
+ not been specified. The new approach has nicer behavior in some
+ locales, including English, which was judged to outweigh the disadvantage
+ of generating less-predictable and often worse output in poorly-configured
+ locales where there is an onus to specify appropriate non-default styles.
+ [The old behavior was introduced in coreutils-6.0 and had been removed
+ for English only using a different method since coreutils-8.1]
+
sort -g now uses long doubles for greater range and precision.
stat no longer accepts the --context (-Z) option. Initially it was
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index f103bd869..5c2bd1a84 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -6927,11 +6927,10 @@ is 80.
@node Formatting file timestamps
@subsection Formatting file timestamps
-By default, file timestamps are listed in abbreviated form. Most
-locales use a timestamp like @samp{2002-03-30 23:45}. However, the
-default @acronym{POSIX} locale uses a date like @samp{Mar 30@ @ 2002}
-for non-recent timestamps, and a date-without-year and time like
-@samp{Mar 30 23:45} for recent timestamps.
+By default, file timestamps are listed in abbreviated form, using
+a date like @samp{Mar 30@ @ 2002} for non-recent timestamps, and a
+date-without-year and time like @samp{Mar 30 23:45} for recent timestamps.
+This format can change depending on the current locale as detailed below.
A timestamp is considered to be @dfn{recent} if it is less than six
months old, and is not dated in the future. If a timestamp dated
diff --git a/src/ls.c b/src/ls.c
index ff0ad2144..6e3e836cb 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2032,7 +2032,6 @@ decode_switches (int argc, char **argv)
break;
case long_iso_time_style:
- case_long_iso_time_style:
long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M";
break;
@@ -2044,17 +2043,10 @@ decode_switches (int argc, char **argv)
case locale_time_style:
if (hard_locale (LC_TIME))
{
- /* Ensure that the locale has translations for both
- formats. If not, fall back on long-iso format. */
int i;
for (i = 0; i < 2; i++)
- {
- char const *locale_format =
- dcgettext (NULL, long_time_format[i], LC_TIME);
- if (locale_format == long_time_format[i])
- goto case_long_iso_time_style;
- long_time_format[i] = locale_format;
- }
+ long_time_format[i] =
+ dcgettext (NULL, long_time_format[i], LC_TIME);
}
}
/* Note we leave %5b etc. alone so user widths/flags are honored. */
diff --git a/tests/misc/ls-time b/tests/misc/ls-time
index 1d10abb38..beea159c2 100755
--- a/tests/misc/ls-time
+++ b/tests/misc/ls-time
@@ -122,4 +122,24 @@ EOF
fail=1
fi
+# This check is ineffective if:
+# en_US locale is not on the system.
+# The system en_US message catalog has a specific TIME_FMT translation,
+# which was inadvertently the case between coreutils 8.1 and 8.5 inclusive.
+
+if gettext --version >/dev/null 2>&1; then
+
+ default_tf1='%b %e %Y'
+ en_tf1=$(LC_ALL=en_US gettext coreutils "$default_tf1")
+
+ if test "$default_tf1" = "$en_tf1"; then
+ LC_ALL=en_US ls -l c >en_output
+ ls -l --time-style=long-iso c >liso_output
+ if compare en_output liso_output; then
+ fail=1
+ echo "Long ISO TIME_FMT being used for en_US locale." >&2
+ fi
+ fi
+fi
+
Exit $fail