OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [mdate-sh] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
#!/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 , 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
 
25
# Prevent date giving response in another language.
26
LANG=C
27
export LANG
28
LC_ALL=C
29
export LC_ALL
30
LC_TIME=C
31
export LC_TIME
32
 
33
# Get the extended ls output of the file or directory.
34
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
35
if ls -L /dev/null 1>/dev/null 2>&1; then
36
  set - x`ls -L -l -d $1`
37
else
38
  set - x`ls -l -d $1`
39
fi
40
# The month is at least the fourth argument
41
# (3 shifts here, the next inside the loop).
42
shift
43
shift
44
shift
45
 
46
# Find the month.  Next argument is day, followed by the year or time.
47
month=
48
until test $month
49
do
50
  shift
51
  case $1 in
52
    Jan) month=January; nummonth=1;;
53
    Feb) month=February; nummonth=2;;
54
    Mar) month=March; nummonth=3;;
55
    Apr) month=April; nummonth=4;;
56
    May) month=May; nummonth=5;;
57
    Jun) month=June; nummonth=6;;
58
    Jul) month=July; nummonth=7;;
59
    Aug) month=August; nummonth=8;;
60
    Sep) month=September; nummonth=9;;
61
    Oct) month=October; nummonth=10;;
62
    Nov) month=November; nummonth=11;;
63
    Dec) month=December; nummonth=12;;
64
  esac
65
done
66
 
67
day=$2
68
 
69
# Here we have to deal with the problem that the ls output gives either
70
# the time of day or the year.
71
case $3 in
72
  *:*) set `date`; eval year=\$$#
73
       case $2 in
74
         Jan) nummonthtod=1;;
75
         Feb) nummonthtod=2;;
76
         Mar) nummonthtod=3;;
77
         Apr) nummonthtod=4;;
78
         May) nummonthtod=5;;
79
         Jun) nummonthtod=6;;
80
         Jul) nummonthtod=7;;
81
         Aug) nummonthtod=8;;
82
         Sep) nummonthtod=9;;
83
         Oct) nummonthtod=10;;
84
         Nov) nummonthtod=11;;
85
         Dec) nummonthtod=12;;
86
       esac
87
       # For the first six month of the year the time notation can also
88
       # be used for files modified in the last year.
89
       if (expr $nummonth \> $nummonthtod) > /dev/null;
90
       then
91
         year=`expr $year - 1`
92
       fi;;
93
  *) year=$3;;
94
esac
95
 
96
# The result.
97
echo $day $month $year

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.