autoconf
[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 14:23:08 +0100

Paul Eggert wrote:
> 
> > Date: Mon, 23 Dec 2002 02:22:35 +0100
> > From: Andreas Buening <address@hidden>
> >
> > What do you think about the following?
> 
> Have you tested it on GNU/Linux?

[snip]

I apologize for this mistake. I guess, I've tested the
wrong mdate-sh. :-(
Next try:

--------------------------------------------
--- old/mdate-sh        Thu Feb 28 09:12:58 2002
+++ new/mdate-sh        Mon Dec 23 12:57:46 2002
@@ -30,24 +30,27 @@
 LC_TIME=C
 export LC_TIME
 
-# Get the extended ls output of the file or directory.
+save_arg1="$1"
+
+# 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`eval $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 +66,28 @@
     Dec) month=December; nummonth=12;;
   esac
 done
+
+# Get the extended ls output of the file or directory.
+set - x`eval $ls_command "\"$save_arg1\""`
+
+# Remove all preceding arguments
+eval $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
--------------------------------------------

This one should really work. I've tested this on three
different Unix systems.


Bye,
Andreas



reply via email to

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