summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-12-19 21:10:52 +0100
committerKevin Ryde <user42@zip.com.au>2003-12-19 21:10:52 +0100
commit748dcec802c77ec3ddf4035f3e531921f557ef41 (patch)
tree418820262d37cb37129c7e4ea4f9c6f7d077cdcb /doc
parent6c5bd578053e555facf63879879d2e23381d4935 (diff)
downloadgmp-748dcec802c77ec3ddf4035f3e531921f557ef41.tar.gz
* */Makefile.in, configure, ansi2knr.c, install.sh, doc/mdate-sh:
Update to automake 1.8.
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/mdate-sh95
1 files changed, 84 insertions, 11 deletions
diff --git a/doc/mdate-sh b/doc/mdate-sh
index c079aed3e..05e828b08 100755
--- a/doc/mdate-sh
+++ b/doc/mdate-sh
@@ -1,6 +1,9 @@
#!/bin/sh
# Get modification time of a file or directory and pretty-print it.
-# Copyright 1995, 1996, 1997 Free Software Foundation, Inc.
+
+scriptversion=2003-11-09.00
+
+# Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
#
# This program is free software; you can redistribute it and/or modify
@@ -22,6 +25,31 @@
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case $1 in
+ '')
+ echo "$0: No file. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: mdate-sh [--help] [--version] FILE
+
+Pretty-print the modification time of FILE.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit 0
+ ;;
+ -v | --v*)
+ echo "mdate-sh $scriptversion"
+ exit 0
+ ;;
+esac
+
# Prevent date giving response in another language.
LANG=C
export LANG
@@ -30,24 +58,38 @@ export LC_ALL
LC_TIME=C
export LC_TIME
-# 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.
+save_arg1="$1"
+
+# Find out how to get the extended ls output of a file or directory.
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.
+# A `ls -l' line looks as follows on OS/2.
+# drwxrwx--- 0 Aug 11 2001 foo
+# This differs from Unix, which adds ownership information.
+# drwxrwx--- 2 root root 4096 Aug 11 2001 foo
+#
+# To find the date, we split the line on spaces and iterate on words
+# until we find a month. This cannot work with files whose owner is a
+# user named `Jan', or `Feb', etc. However, it's unlikely that `/'
+# will be owned by a user whose name is a month. So we first look at
+# the extended ls output of the root directory to decide how many
+# 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_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;;
@@ -64,6 +106,28 @@ do
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
# Here we have to deal with the problem that the ls output gives either
@@ -95,3 +159,12 @@ esac
# The result.
echo $day $month $year
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End: