* Eric Blake wrote on Wed, Mar 28, 2007 at 06:41:03PM CEST: > Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes: > > > > It would be even better if it came with a test to ensure correct > > functioning of the script, as far as portably possible. For example, > > it could test that three words are output, and that day and year are > > numeric. (As usual, I can write the test, but if you do it, then it > > will be done more quickly > > I'll see what I can come up with, but it may be a few days before I have time > to focus on it (I'm about to head out of town for the weekend).
Don't worry; FWIW, I'm about to be off soon as well. I committed the patch below to HEAD and branch-1-10. Could you (or somebody else) please make sure that the new test exposes the bug that was fixed, on your Cygwin? Thanks. Cheers, Ralf 2007-03-30 Eric Blake <[EMAIL PROTECTED]> Ralf Wildenhues <[EMAIL PROTECTED]> * lib/mdate-sh (ls_command): Use -n when available to avoid problems with spaces in user/group names. * tests/mdate5.test: New test. * tests/Makefile.am: Adjust. Index: lib/mdate-sh =================================================================== RCS file: /cvs/automake/automake/lib/mdate-sh,v retrieving revision 1.18 diff -u -r1.18 mdate-sh --- lib/mdate-sh 29 Jun 2005 20:29:24 -0000 1.18 +++ lib/mdate-sh 29 Mar 2007 23:22:15 -0000 @@ -1,9 +1,9 @@ #!/bin/sh # Get modification time of a file or directory and pretty-print it. -scriptversion=2005-06-29.22 +scriptversion=2007-03-30.02 -# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 Free Software +# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005, 2007 Free Software # Foundation, Inc. # written by Ulrich Drepper <[EMAIL PROTECTED]>, June 1995 # @@ -75,6 +75,10 @@ else ls_command='ls -l -d' fi +# Avoid user/group names that might have spaces, when possible. +if ls -n /dev/null 1>/dev/null 2>&1; then + ls_command="$ls_command -n" +fi # A `ls -l' line looks as follows on OS/2. # drwxrwx--- 0 Aug 11 2001 foo @@ -89,7 +93,7 @@ # words should be skipped to get the date. # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. -set x`ls -l -d /` +set x`$ls_command /` # Find which argument is the month. month= Index: tests/Makefile.am =================================================================== RCS file: /cvs/automake/automake/tests/Makefile.am,v retrieving revision 1.620 diff -u -r1.620 Makefile.am --- tests/Makefile.am 29 Mar 2007 23:02:05 -0000 1.620 +++ tests/Makefile.am 29 Mar 2007 23:22:15 -0000 @@ -367,6 +367,7 @@ mdate2.test \ mdate3.test \ mdate4.test \ +mdate5.test \ missing.test \ missing2.test \ missing3.test \ --- /dev/null 2007-03-24 19:16:22.324321248 +0100 +++ tests/mdate5.test 2007-03-30 01:23:22.000000000 +0200 @@ -0,0 +1,48 @@ +#! /bin/sh +# Copyright (C) 1999, 2001, 2002, 2004, 2007 Free Software Foundation, +# Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +# Test to make sure mdate-sh works correctly. + +. ./defs || exit 1 +set -e + +cat >> configure.in << 'END' +AC_OUTPUT +END + +cat > Makefile.am << 'END' +info_TEXINFOS = textutils.texi +END + +cat > textutils.texi << 'END' [EMAIL PROTECTED] version.texi [EMAIL PROTECTED] textutils.info +END + +$ACLOCAL +$AUTOMAKE --add-missing + +set x `$SHELL ./mdate-sh Makefile.am` +shift +# Check that mdate output looks like a date: +test $# = 3 +case $1$3 in *[!0-9]*) exit 1;; esac +test $1 -lt 32