7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# Get modification time of a file or directory and pretty-print it.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005, 2007 Free Software
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# Foundation, Inc.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# This program is free software; you can redistribute it and/or modify
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# it under the terms of the GNU General Public License as published by
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# the Free Software Foundation; either version 3, or (at your option)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# any later version.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# This program is distributed in the hope that it will be useful,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# but WITHOUT ANY WARRANTY; without even the implied warranty of
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# GNU General Public License for more details.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# You should have received a copy of the GNU General Public License
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# along with this program; if not, write to the Free Software Foundation,
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# As a special exception to the GNU General Public License, if you
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# distribute this file as part of a program that contains a
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# configuration script generated by Autoconf, you may include it under
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# the same distribution terms that you use for the rest of that program.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# This file is maintained in Automake, please report
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# bugs to <bug-automake@gnu.org> or send patches to
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# <automake-patches@gnu.org>.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding echo "$0: No file. Try \`$0 --help' for more information." 1>&2
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding echo "mdate-sh $scriptversion"
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding# Prevent date giving response in another language.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# GNU ls changes its time format in response to the TIME_STYLE
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# variable. Since we cannot assume `unset' works, revert this
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# variable to its documented default.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingif test "${TIME_STYLE+set}" = set; then
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# Find out how to get the extended ls output of a file or directory.
b6055b7832a0e4d0818416252fff5925aaebae4brbb# Avoid user/group names that might have spaces, when possible.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# A `ls -l' line looks as follows on OS/2.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# drwxrwx--- 0 Aug 11 2001 foo
2e123e8beedc9f921448c113e2d6823a92fd5261fielding# This differs from Unix, which adds ownership information.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# drwxrwx--- 2 root root 4096 Aug 11 2001 foo
d14bedfcd8626fc48770ee31e7c42de4924aaa6btrawick# To find the date, we split the line on spaces and iterate on words
d14bedfcd8626fc48770ee31e7c42de4924aaa6btrawick# until we find a month. This cannot work with files whose owner is a
d14bedfcd8626fc48770ee31e7c42de4924aaa6btrawick# user named `Jan', or `Feb', etc. However, it's unlikely that `/'
d41217398f0e1031adbb6f5bd37f45737c805deftrawick# will be owned by a user whose name is a month. So we first look at
d41217398f0e1031adbb6f5bd37f45737c805deftrawick# the extended ls output of the root directory to decide how many
d41217398f0e1031adbb6f5bd37f45737c805deftrawick# words should be skipped to get the date.
e68becff3c3ddc18723c9799b8cc2e6e9c3dbd66wrowe# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
30c289e6bc6d28d210b21edd800ab2cfc78a8381wrowe# Find which argument is the month.
ff72a628571224579194f37cf8db96186ae889a5dougm # Add another shift to the command.
f38c43f9ec3b63dc40bdb7132ff4975bd4c9ae9crbb command="$command shift;"
36bb027ff0af9d285d15e9fac4fc956db6c33e94wrowe# Get the extended ls output of the file or directory.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# Remove all preceding arguments
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# Because of the dummy argument above, month is in $2.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# On a POSIX system, we should have
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# $1 = file size
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# $2 = month
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# $4 = year or time
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# $5 = filename
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# On Darwin 7.7.0 and 7.6.0, we have
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# $2 = month
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm# $3 = year or time
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm# $4 = filename
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# Get the month.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# Here we have to deal with the problem that the ls output gives either
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# the time of day or the year.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding # For the first six month of the year the time notation can also
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding # be used for files modified in the last year.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# The result.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# Local Variables:
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm# mode: shell-script
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# sh-indentation: 2
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# eval: (add-hook 'write-file-hooks 'time-stamp)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# time-stamp-start: "scriptversion="
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# time-stamp-format: "%:y-%02m-%02d.%02H"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding# time-stamp-end: "$"