source: trunk/essentials/sys-apps/diffutils/config/mdate-sh

Last change on this file was 3044, checked in by bird, 18 years ago

hack for bad ls.

File size: 2.9 KB
Line 
1#!/bin/sh
2# Get modification time of a file or directory and pretty-print it.
3# Copyright 1995, 1996, 1997 Free Software Foundation, Inc.
4# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software Foundation,
18# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20# As a special exception to the GNU General Public License, if you
21# distribute this file as part of a program that contains a
22# configuration script generated by Autoconf, you may include it under
23# the same distribution terms that you use for the rest of that program.
24
25set -x
26
27# Prevent date giving response in another language.
28LANG=C
29export LANG
30LC_ALL=C
31export LC_ALL
32LC_TIME=C
33export LC_TIME
34
35# Get the extended ls output of the file or directory.
36# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
37if ls -L /dev/null 1>/dev/null 2>&1; then
38 set - x`ls -L -l -d $1`
39else
40 set - x`ls -l -d $1`
41fi
42# The month is at least the fourth argument
43# (3 shifts here, the next inside the loop).
44shift
45#shift
46#shift
47
48# Find the month. Next argument is day, followed by the year or time.
49month=
50until test $month
51do
52 shift
53 case $1 in
54 Jan) month=January; nummonth=1;;
55 Feb) month=February; nummonth=2;;
56 Mar) month=March; nummonth=3;;
57 Apr) month=April; nummonth=4;;
58 May) month=May; nummonth=5;;
59 Jun) month=June; nummonth=6;;
60 Jul) month=July; nummonth=7;;
61 Aug) month=August; nummonth=8;;
62 Sep) month=September; nummonth=9;;
63 Oct) month=October; nummonth=10;;
64 Nov) month=November; nummonth=11;;
65 Dec) month=December; nummonth=12;;
66 esac
67done
68
69day=$2
70
71# Here we have to deal with the problem that the ls output gives either
72# the time of day or the year.
73case $3 in
74 *:*) set `date`; eval year=\$$#
75 case $2 in
76 Jan) nummonthtod=1;;
77 Feb) nummonthtod=2;;
78 Mar) nummonthtod=3;;
79 Apr) nummonthtod=4;;
80 May) nummonthtod=5;;
81 Jun) nummonthtod=6;;
82 Jul) nummonthtod=7;;
83 Aug) nummonthtod=8;;
84 Sep) nummonthtod=9;;
85 Oct) nummonthtod=10;;
86 Nov) nummonthtod=11;;
87 Dec) nummonthtod=12;;
88 esac
89 # For the first six month of the year the time notation can also
90 # be used for files modified in the last year.
91 if (expr $nummonth \> $nummonthtod) > /dev/null;
92 then
93 year=`expr $year - 1`
94 fi;;
95 *) year=$3;;
96esac
97
98# The result.
99echo $day $month $year
Note: See TracBrowser for help on using the repository browser.