bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mdate-sh


From: Andreas Buening
Subject: Re: mdate-sh
Date: Mon, 23 Dec 2002 02:22:35 +0100

Paul Eggert wrote:
> 
> > Date: Fri, 20 Dec 2002 00:06:26 +0100
> > From: Andreas Buening <address@hidden>

I have a question concerning config/mdate-sh.
It contains the following code:

----------------------
# Get the extended ls output of the file or directory.
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x"
below.
if ls -L /dev/null 1>/dev/null 2>&1; then
  set - x`ls -L -l -d $1`
else
  set - x`ls -l -d $1`
fi
# The month is at least the fourth argument
# (3 shifts here, the next inside the loop).
shift
shift
shift
----------------------

> > The problem is that "ls -l" on OS/2 delivers the month in the
> > third column.
> 
> What exactly does the "ls -l" line look like?

drwxrwx---        0 Aug 11  2001 foo

 
> > Would it be possible to a) either remove two of the "shift" commands
> > or b) use "ls -n -l" (provided that "-n" is standardized)?
> 
> Unfortunately -n wasn't in Unix Version 7 and is not required by
> POSIX (it's an XSI extension), so we can't rely on it.
> 
> Perhaps the most reliable algorithm is to parse the output of "ls -ld
> /" and look for a month, and use that to figure out how many columns
> to shift.  It's unlikely that / will be owned by a user whose name is
> a month.
> 
> Can you please propose a patch (diff -u output) and send it to
> address@hidden  Automake owns mdate-sh.  Thanks.


What do you think about the following?

-------------------------------------------
--- old/mdate-sh        Thu Feb 28 09:12:58 2002
+++ new/mdate-sh        Mon Dec 23 02:06:04 2002
@@ -30,24 +30,25 @@
 LC_TIME=C
 export LC_TIME
 
-# Get the extended ls output of the file or directory.
+# Find out how to get the extended ls output of a file or directory.
 # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
 if ls -L /dev/null 1>/dev/null 2>&1; then
-  set - x`ls -L -l -d $1`
+  ls_command='ls -L -l -d'
 else
-  set - x`ls -l -d $1`
+  ls_command='ls -l -d'
 fi
-# The month is at least the fourth argument
-# (3 shifts here, the next inside the loop).
-shift
-shift
-shift
 
-# Find the month.  Next argument is day, followed by the year or time.
+# Get the extended ls output of the root directory.
+set - x`$ls_command /`
+
+# Find which argument is the month.
 month=
+command=
 until test $month
 do
   shift
+  # Add another shift to the command.
+  command="$command shift;"
   case $1 in
     Jan) month=January; nummonth=1;;
     Feb) month=February; nummonth=2;;
@@ -63,6 +64,28 @@
     Dec) month=December; nummonth=12;;
   esac
 done
+
+# Get the extended ls output of the file or directory.
+set - x`$ls_command $1`
+
+# Remove all preceeding arguments
+$command
+
+# Get the month.  Next argument is day, followed by the year or time.
+case $1 in
+  Jan) month=January; nummonth=1;;
+  Feb) month=February; nummonth=2;;
+  Mar) month=March; nummonth=3;;
+  Apr) month=April; nummonth=4;;
+  May) month=May; nummonth=5;;
+  Jun) month=June; nummonth=6;;
+  Jul) month=July; nummonth=7;;
+  Aug) month=August; nummonth=8;;
+  Sep) month=September; nummonth=9;;
+  Oct) month=October; nummonth=10;;
+  Nov) month=November; nummonth=11;;
+  Dec) month=December; nummonth=12;;
+esac
 
 day=$2
-------------------------------------------


Bye,
Andreas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]