[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
mdate-sh vs. evil user/group names
From: |
Eric Blake |
Subject: |
mdate-sh vs. evil user/group names |
Date: |
Thu, 1 Mar 2007 22:24:14 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
mdate-sh fails miserably in the presence of user/group names that contain
spaces (bad practice, but particularly common on cygwin). Currently, the
script tries to figure out where the first field containing a month name
appears when looking at /, then uses that information to grab the same field in
the target file. The net result when the two commands have a different number
of fields, due to poorly placed spaces? A horribly botched date string.
$ \ls -ld /
drwxrwx---+ 14 eblake Users 0 Feb 2 07:58 /
$ \ls -lLd doc/m4.texinfo
-rw-r--r-- 1 eblake Domain Users 221922 Mar 1 14:50 doc/m4.texinfo
$ doc/mdate-sh doc/m4.texinfo
Users February Mar
OK to apply this patch?
2007-03-01 Eric Blake <address@hidden>
* lib/mdate-sh (ls_command): Use -n when available to avoid
problems with spaces in user/group names.
--- ../gnulib/build-aux/mdate-sh 2005-07-01 07:17:41.000000000 -0600
+++ lib/mdate-sh 2007-03-01 15:03:45.526362700 -0700
@@ -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-01.15
-# 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 <address@hidden>, 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=
- mdate-sh vs. evil user/group names,
Eric Blake <=