diff options
| author | Pádraig Brady <P@draigBrady.com> | 2024-06-27 18:15:02 +0100 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2024-06-27 18:37:23 +0100 |
| commit | b95c6ac7d20084d9167bdb9d759bcebcb0c2b766 (patch) | |
| tree | b1352e6743d99d6042a85bb6339d78fd2874d20a /tests/ls | |
| parent | 72588b291594c762133090ef24fcad8894fc91f6 (diff) | |
| download | coreutils-b95c6ac7d20084d9167bdb9d759bcebcb0c2b766.tar.gz coreutils-b95c6ac7d20084d9167bdb9d759bcebcb0c2b766.zip | |
ls: treat --time=mtime consistently with other time selectors
* src/ls.c: Track if --time=mtime is explicitly specified,
so that we can apply the GNU extension of sorting by the
specified time, when not displaying (-l not specified),
and not explicitly sorting (-t not specified).
* tests/ls/ls-time.sh: Add / Update test cases.
Fixes https://bugs.gnu.org/71803
Diffstat (limited to 'tests/ls')
| -rwxr-xr-x | tests/ls/ls-time.sh | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/tests/ls/ls-time.sh b/tests/ls/ls-time.sh index f27a5dbbe..be8a83556 100755 --- a/tests/ls/ls-time.sh +++ b/tests/ls/ls-time.sh @@ -33,11 +33,15 @@ u2='1998-01-14 12:00' u3='1998-01-14 13:00' touch -m -d "$t3" a || framework_failure_ -touch -m -d "$t2" b || framework_failure_ +touch -m -d "$t2" B || framework_failure_ # Capital to distinguish name sort touch -m -d "$t1" c || framework_failure_ +# Check default name sorting works +set $(ls a B c) +test "$*" = 'B a c' || fail=1 + touch -a -d "$u3" c || framework_failure_ -touch -a -d "$u2" b || framework_failure_ +touch -a -d "$u2" B || framework_failure_ # Make sure A has ctime at least 1 second more recent than C's. sleep 2 touch -a -d "$u1" a || framework_failure_ @@ -47,7 +51,9 @@ touch -a -d "$u1" a || framework_failure_ # A has ctime more recent than C. -set $(ls -c a c) +set $(ls -t -c a c) +test "$*" = 'a c' || fail=1 +set $(ls -c a c) # Not specified by POSIX test "$*" = 'a c' || fail=1 # Sleep so long in an attempt to avoid spurious failures @@ -93,13 +99,17 @@ EOF ;; esac -set $(ls -ut a b c) -test "$*" = 'c b a' && : || fail=1 -test $fail = 1 && ls -l --full-time --time=access a b c - -set $(ls -t a b c) -test "$*" = 'a b c' && : || fail=1 -test $fail = 1 && ls -l --full-time a b c +set $(ls -ut a B c) +test "$*" = 'c B a' || fail=1 +set $(ls -u a B c) # not specified by POSIX +test "$*" = 'c B a' || fail=1 +test $fail = 1 && ls -l --full-time --time=access a B c + +set $(ls -t a B c) +test "$*" = 'a B c' || fail=1 +set $(ls --time=mtime a B c) +test "$*" = 'a B c' || fail=1 +test $fail = 1 && ls -l --full-time a B c # Now, C should have ctime more recent than A. set $(ls -ct a c) |
