mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
34 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b73a1b844f | ||
|
|
59f3e7dfea | ||
|
|
78df00cae0 | ||
|
|
745cee714a | ||
|
|
6d16699fff | ||
|
|
ea44cc33ca | ||
|
|
4db847ce3c | ||
|
|
231813e179 | ||
|
|
1c3a5c6ff8 | ||
|
|
72e1d14aec | ||
|
|
584f4d85cf | ||
|
|
9096ee8e42 | ||
|
|
f7c0efdba2 | ||
|
|
a3c0837bc3 | ||
|
|
834b042b93 | ||
|
|
f0e77e8722 | ||
|
|
5c094d2ab2 | ||
|
|
1eb146483f | ||
|
|
1b3c2bbb06 | ||
|
|
edbbc8335c | ||
|
|
48405e4b9c | ||
|
|
f9ae8064f2 | ||
|
|
9ce9d75ddb | ||
|
|
d59ce5651c | ||
|
|
981c203fab | ||
|
|
c0385fb129 | ||
|
|
ac88b78ef3 | ||
|
|
e01fce9e16 | ||
|
|
164bff8dc0 | ||
|
|
7b7b9007db | ||
|
|
c0ad97a781 | ||
|
|
c5a9a5f563 | ||
|
|
b363124be4 | ||
|
|
d06d2de67c |
1
THANKS
1
THANKS
@@ -3,6 +3,7 @@ The rest of the addresses are still in the ChangeLog.
|
||||
|
||||
Achim Blumensath: blume@corona.oche.de
|
||||
Andreas Schwab: schwab@issan.informatik.uni-dortmund.de
|
||||
Andries Brouwer: Andries.Brouwer@cwi.nl
|
||||
Arne Henrik Juul: arnej@imf.unit.no
|
||||
Bauke Jan Douma: bjdouma@xs4all.nl
|
||||
Bengt Martensson: bengt@mathematik.uni-Bremen.de
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
Makefile
|
||||
getdate.c
|
||||
posixtm.c
|
||||
safe-stat.h
|
||||
safe-stat.c
|
||||
safe-lstat.c
|
||||
|
||||
@@ -6,7 +6,7 @@ noinst_LIBRARIES = libfu.a
|
||||
|
||||
INCLUDES = -I.. -I$(srcdir) -I../intl
|
||||
|
||||
libfu_a_SOURCES = getdate.y posixtm.y getopt.c getopt1.c \
|
||||
libfu_a_SOURCES = getdate.y posixtm.c getopt.c getopt1.c \
|
||||
addext.c argmatch.c backupfile.c basename.c \
|
||||
closeout.c dirname.c exclude.c filemode.c \
|
||||
full-write.c human.c idcache.c \
|
||||
@@ -21,7 +21,7 @@ noinst_HEADERS = argmatch.h backupfile.h closeout.h \
|
||||
error.h exclude.h filemode.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
xalloc.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c posixtm.c
|
||||
BUILT_SOURCES = getdate.c
|
||||
|
||||
@@ -95,7 +95,7 @@ noinst_LIBRARIES = libfu.a
|
||||
|
||||
INCLUDES = -I.. -I$(srcdir) -I../intl
|
||||
|
||||
libfu_a_SOURCES = getdate.y posixtm.y getopt.c getopt1.c \
|
||||
libfu_a_SOURCES = getdate.y posixtm.c getopt.c getopt1.c \
|
||||
addext.c argmatch.c backupfile.c basename.c \
|
||||
closeout.c dirname.c exclude.c filemode.c \
|
||||
full-write.c human.c idcache.c \
|
||||
@@ -110,10 +110,10 @@ noinst_HEADERS = argmatch.h backupfile.h closeout.h \
|
||||
error.h exclude.h filemode.h fnmatch.h fsusage.h \
|
||||
getdate.h getline.h getopt.h group-member.h human.h lchown.h long-options.h \
|
||||
makepath.h modechange.h mountlist.h hash.h path-concat.h pathmax.h \
|
||||
quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
posixtm.h quotearg.h regex.h safe-read.h save-cwd.h savedir.h strverscmp.h \
|
||||
xalloc.h xstrtol.h xstrtoul.h
|
||||
|
||||
BUILT_SOURCES = getdate.c posixtm.c
|
||||
BUILT_SOURCES = getdate.c
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
@@ -133,7 +133,6 @@ hash$U.o path-concat$U.o quotearg$U.o safe-read$U.o save-cwd$U.o \
|
||||
savedir$U.o stripslash$U.o userspec$U.o xgetcwd$U.o xmalloc$U.o \
|
||||
xstrdup$U.o xstrtol$U.o xstrtoul$U.o yesno$U.o
|
||||
AR = ar
|
||||
YLWRAP = $(srcdir)/ylwrap
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
@@ -143,9 +142,9 @@ DIST_COMMON = Makefile.am Makefile.in TODO alloca.c chown.c error.c \
|
||||
error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c \
|
||||
getdate.c getgroups.c getline.c group-member.c lchown.c lstat.c \
|
||||
malloc.c memcmp.c memcpy.c memset.c mkdir.c mktime.c mountlist.c \
|
||||
obstack.c obstack.h posixtm.c realloc.c regex.c rename.c rmdir.c \
|
||||
rpmatch.c stat.c stpcpy.c strcasecmp.c strdup.c strftime.c strndup.c \
|
||||
strstr.c strtol.c strtoul.c strverscmp.c utime.c ylwrap
|
||||
obstack.c obstack.h realloc.c regex.c rename.c rmdir.c rpmatch.c stat.c \
|
||||
stpcpy.c strcasecmp.c strdup.c strftime.c strndup.c strstr.c strtol.c \
|
||||
strtoul.c strverscmp.c utime.c ylwrap
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
@@ -162,15 +161,14 @@ DEP_FILES = .deps/addext.P .deps/alloca.P .deps/argmatch.P \
|
||||
.deps/isdir.P .deps/lchown.P .deps/long-options.P .deps/lstat.P \
|
||||
.deps/makepath.P .deps/malloc.P .deps/memcmp.P .deps/memcpy.P \
|
||||
.deps/memset.P .deps/mkdir.P .deps/mktime.P .deps/modechange.P \
|
||||
.deps/mountlist.P .deps/obstack.P .deps/path-concat.P .deps/posixtm \
|
||||
.deps/posixtm.P .deps/quotearg.P .deps/realloc.P .deps/regex.P \
|
||||
.deps/rename.P .deps/rmdir.P .deps/rpmatch.P .deps/safe-read.P \
|
||||
.deps/save-cwd.P .deps/savedir.P .deps/stat.P .deps/stpcpy.P \
|
||||
.deps/strcasecmp.P .deps/strdup.P .deps/strftime.P .deps/stripslash.P \
|
||||
.deps/strndup.P .deps/strstr.P .deps/strtol.P .deps/strtoul.P \
|
||||
.deps/strverscmp.P .deps/userspec.P .deps/utime.P .deps/xgetcwd.P \
|
||||
.deps/xmalloc.P .deps/xstrdup.P .deps/xstrtol.P .deps/xstrtoul.P \
|
||||
.deps/yesno.P
|
||||
.deps/mountlist.P .deps/obstack.P .deps/path-concat.P .deps/posixtm.P \
|
||||
.deps/quotearg.P .deps/realloc.P .deps/regex.P .deps/rename.P \
|
||||
.deps/rmdir.P .deps/rpmatch.P .deps/safe-read.P .deps/save-cwd.P \
|
||||
.deps/savedir.P .deps/stat.P .deps/stpcpy.P .deps/strcasecmp.P \
|
||||
.deps/strdup.P .deps/strftime.P .deps/stripslash.P .deps/strndup.P \
|
||||
.deps/strstr.P .deps/strtol.P .deps/strtoul.P .deps/strverscmp.P \
|
||||
.deps/userspec.P .deps/utime.P .deps/xgetcwd.P .deps/xmalloc.P \
|
||||
.deps/xstrdup.P .deps/xstrtol.P .deps/xstrtoul.P .deps/yesno.P
|
||||
SOURCES = $(libfu_a_SOURCES)
|
||||
OBJECTS = $(libfu_a_OBJECTS)
|
||||
|
||||
@@ -231,8 +229,10 @@ libfu.a: $(libfu_a_OBJECTS) $(libfu_a_DEPENDENCIES)
|
||||
$(AR) cru libfu.a $(libfu_a_OBJECTS) $(libfu_a_LIBADD)
|
||||
$(RANLIB) libfu.a
|
||||
.y.c:
|
||||
$(SHELL) $(YLWRAP) "$(YACC)" $< y.tab.c $*.c y.tab.h $*.h -- $(YFLAGS)
|
||||
posixtm.h: posixtm.c
|
||||
$(YACC) $(YFLAGS) $< && mv y.tab.c $*.c
|
||||
if test -f y.tab.h; then \
|
||||
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
|
||||
else :; fi
|
||||
getdate.h: getdate.c
|
||||
|
||||
addext_.c: addext.c $(ANSI2KNR)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* modechange.c -- file mode manipulation
|
||||
Copyright (C) 1989, 1990, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989, 1990, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -35,7 +35,7 @@
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
char *malloc;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
@@ -55,7 +55,22 @@ char *malloc ();
|
||||
|
||||
#define isodigit(c) ((c) >= '0' && (c) <= '7')
|
||||
|
||||
static int oatoi ();
|
||||
/* Return a positive integer containing the value of the ASCII
|
||||
octal number S. If S is not an octal number, return -1. */
|
||||
|
||||
static int
|
||||
oatoi (const char *s)
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (*s == 0)
|
||||
return -1;
|
||||
for (i = 0; isodigit (*s); ++s)
|
||||
i = i * 8 + *s - '0';
|
||||
if (*s)
|
||||
return -1;
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Return a linked list of file mode change operations created from
|
||||
MODE_STRING, an ASCII string that contains either an octal number
|
||||
@@ -71,9 +86,7 @@ static int oatoi ();
|
||||
return MODE_MEMORY_EXHAUSTED if there is insufficient memory. */
|
||||
|
||||
struct mode_change *
|
||||
mode_compile (mode_string, masked_ops)
|
||||
const char *mode_string;
|
||||
unsigned masked_ops;
|
||||
mode_compile (const char *mode_string, unsigned int masked_ops)
|
||||
{
|
||||
struct mode_change *head; /* First element of the linked list. */
|
||||
struct mode_change *change; /* An element of the linked list. */
|
||||
@@ -240,8 +253,7 @@ invalid:
|
||||
of REF_FILE. Return MODE_BAD_REFERENCE if REF_FILE can't be accessed. */
|
||||
|
||||
struct mode_change *
|
||||
mode_create_from_ref (ref_file)
|
||||
const char *ref_file;
|
||||
mode_create_from_ref (const char *ref_file)
|
||||
{
|
||||
struct mode_change *change; /* the only change element */
|
||||
struct stat ref_stats;
|
||||
@@ -269,9 +281,7 @@ mode_create_from_ref (ref_file)
|
||||
The returned value has the S_IFMT bits cleared. */
|
||||
|
||||
unsigned short
|
||||
mode_adjust (oldmode, changes)
|
||||
unsigned oldmode;
|
||||
const struct mode_change *changes;
|
||||
mode_adjust (unsigned int oldmode, const struct mode_change *changes)
|
||||
{
|
||||
unsigned short newmode; /* The adjusted mode and one operand. */
|
||||
unsigned short value; /* The other operand. */
|
||||
@@ -336,8 +346,7 @@ mode_adjust (oldmode, changes)
|
||||
CHANGES. */
|
||||
|
||||
void
|
||||
mode_free (changes)
|
||||
register struct mode_change *changes;
|
||||
mode_free (register struct mode_change *changes)
|
||||
{
|
||||
register struct mode_change *next;
|
||||
|
||||
@@ -348,21 +357,3 @@ mode_free (changes)
|
||||
changes = next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return a positive integer containing the value of the ASCII
|
||||
octal number S. If S is not an octal number, return -1. */
|
||||
|
||||
static int
|
||||
oatoi (s)
|
||||
char *s;
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (*s == 0)
|
||||
return -1;
|
||||
for (i = 0; isodigit (*s); ++s)
|
||||
i = i * 8 + *s - '0';
|
||||
if (*s)
|
||||
return -1;
|
||||
return i;
|
||||
}
|
||||
|
||||
1135
lib/posixtm.c
1135
lib/posixtm.c
File diff suppressed because it is too large
Load Diff
16
lib/posixtm.h
Normal file
16
lib/posixtm.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef POSIXTM_H_
|
||||
# define POSIXTM_H_
|
||||
|
||||
/* POSIX Date Syntax flags. */
|
||||
# define PDS_LEADING_YEAR 1
|
||||
# define PDS_TRAILING_YEAR 2
|
||||
# define PDS_CENTURY 4
|
||||
# define PDS_SECONDS 8
|
||||
|
||||
time_t
|
||||
posixtime (const char *s, unsigned int syntax_bits);
|
||||
|
||||
struct tm *
|
||||
posixtm (const char *s, unsigned int syntax_bits);
|
||||
|
||||
#endif
|
||||
2
man/chgrp.x
Normal file
2
man/chgrp.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
55
man/chmod.x
Normal file
55
man/chmod.x
Normal file
@@ -0,0 +1,55 @@
|
||||
[DESCRIPTION]
|
||||
This manual page
|
||||
documents the GNU version of
|
||||
.BR chmod .
|
||||
.B chmod
|
||||
changes the permissions of each given file according to
|
||||
.IR mode ,
|
||||
which can be either a symbolic representation of changes to make, or
|
||||
an octal number representing the bit pattern for the new permissions.
|
||||
.PP
|
||||
The format of a symbolic mode is
|
||||
`[ugoa...][[+-=][rwxXstugo...]...][,...]'. Multiple symbolic
|
||||
operations can be given, separated by commas.
|
||||
.PP
|
||||
A combination of the letters `ugoa' controls which users' access to
|
||||
the file will be changed: the user who owns it (u), other users in the
|
||||
file's group (g), other users not in the file's group (o), or all
|
||||
users (a). If none of these are given, the effect is as if `a' were
|
||||
given, but bits that are set in the umask are not affected.
|
||||
.PP
|
||||
The operator `+' causes the permissions selected to be added to the
|
||||
existing permissions of each file; `-' causes them to be removed; and
|
||||
`=' causes them to be the only permissions that the file has.
|
||||
.PP
|
||||
The letters `rwxXstugo' select the new permissions for the affected
|
||||
users: read (r), write (w), execute (or access for directories) (x),
|
||||
execute only if the file is a directory or already has execute
|
||||
permission for some user (X), set user or group ID on execution (s),
|
||||
save program text on swap device (t), the permissions that the user
|
||||
who owns the file currently has for it (u), the permissions that other
|
||||
users in the file's group have for it (g), and the permissions that
|
||||
other users not in the file's group have for it (o).
|
||||
.PP
|
||||
A numeric mode is from one to four octal digits (0-7), derived by
|
||||
adding up the bits with values 4, 2, and 1. Any omitted digits are
|
||||
assumed to be leading zeros. The first digit selects the set user ID
|
||||
(4) and set group ID (2) and save text image (1) attributes. The
|
||||
second digit selects permissions for the user who owns the file: read
|
||||
(4), write (2), and execute (1); the third selects permissions for
|
||||
other users in the file's group, with the same values; and the fourth
|
||||
for other users not in the file's group, with the same values.
|
||||
.PP
|
||||
.B chmod
|
||||
never changes the permissions of symbolic links; the
|
||||
.B chmod
|
||||
system call cannot change their permissions. This is not a problem
|
||||
since the permissions of symbolic links are never used.
|
||||
However, for each symbolic link listed on the command line,
|
||||
.B chmod
|
||||
changes the permissions of the pointed-to file.
|
||||
In contrast,
|
||||
.B chmod
|
||||
ignores symbolic links encountered during recursive directory
|
||||
traversals.
|
||||
.SH OPTIONS
|
||||
20
man/chown.x
Normal file
20
man/chown.x
Normal file
@@ -0,0 +1,20 @@
|
||||
[DESCRIPTION]
|
||||
This manual page
|
||||
documents the GNU version of
|
||||
.BR chown .
|
||||
.B chown
|
||||
changes the user and/or group ownership of each given file, according
|
||||
to its first non-option argument, which is interpreted as follows. If
|
||||
only a user name (or numeric user ID) is given, that user is made the
|
||||
owner of each given file, and the files' group is not changed. If the
|
||||
user name is followed by a colon or dot and a group name (or numeric group ID),
|
||||
with no spaces between them, the group ownership of the files is
|
||||
changed as well. If a colon or dot but no group name follows the user name,
|
||||
that user is made the owner of the files and the group of the files is
|
||||
changed to that user's login group. If the colon or dot and group are given,
|
||||
but the user name is omitted, only the group of the files is changed;
|
||||
in this case,
|
||||
.B chown
|
||||
performs the same function as
|
||||
.BR chgrp .
|
||||
.Sh OPTIONS
|
||||
18
man/cp.x
Normal file
18
man/cp.x
Normal file
@@ -0,0 +1,18 @@
|
||||
.\" Copyright (C) 1994, 95, 96, 97 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" Permission is granted to make and distribute verbatim copies of this
|
||||
.\" manual provided the copyright notice and this permission notice are
|
||||
.\" preserved on all copies.
|
||||
.\"
|
||||
.\" Permission is granted to copy and distribute modified versions of
|
||||
.\" this manual under the conditions for verbatim copying, provided that
|
||||
.\" the entire resulting derived work is distributed under the terms of a
|
||||
.\" permission notice identical to this one.
|
||||
.\"
|
||||
.\" Permission is granted to copy and distribute translations of this
|
||||
.\" manual into another language, under the above conditions for modified
|
||||
.\" versions, except that this permission notice may be stated in a
|
||||
.\" translation approved by the Foundation.
|
||||
.\"
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
2
man/dd.x
Normal file
2
man/dd.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
39
man/df.x
Normal file
39
man/df.x
Normal file
@@ -0,0 +1,39 @@
|
||||
.\" Copyright (C) 1994, 95, 96, 97, 98 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" Permission is granted to make and distribute verbatim copies of this
|
||||
.\" manual provided the copyright notice and this permission notice are
|
||||
.\" preserved on all copies.
|
||||
.\"
|
||||
.\" Permission is granted to copy and distribute modified versions of
|
||||
.\" this manual under the conditions for verbatim copying, provided that
|
||||
.\" the entire resulting derived work is distributed under the terms of a
|
||||
.\" permission notice identical to this one.
|
||||
.\"
|
||||
.\" Permission is granted to copy and distribute translations of this
|
||||
.\" manual into another language, under the above conditions for modified
|
||||
.\" versions, except that this permission notice may be stated in a
|
||||
.\" translation approved by the Foundation.
|
||||
.\"
|
||||
[DESCRIPTION]
|
||||
This manual page
|
||||
documents the GNU version of
|
||||
.BR df .
|
||||
.B df
|
||||
displays the amount of disk space available on the filesystem
|
||||
containing each file name argument. If no file name is given, the
|
||||
space available on all currently mounted filesystems is shown. Disk
|
||||
space is shown in 1K blocks by default, unless the environment
|
||||
variable POSIXLY_CORRECT is set, in which case 512-byte blocks are
|
||||
used.
|
||||
.PP
|
||||
If an argument is the absolute file name of a disk device node containing a
|
||||
mounted filesystem,
|
||||
.B df
|
||||
shows the space available on that filesystem rather than on the
|
||||
filesystem containing the device node (which is always the root
|
||||
filesystem). This version of
|
||||
.B df
|
||||
cannot show the space available on unmounted filesystems, because on
|
||||
most kinds of systems doing so requires very nonportable intimate
|
||||
knowledge of filesystem structures.
|
||||
.SH OPTIONS
|
||||
2
man/dir.x
Normal file
2
man/dir.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
2
man/dircolors.x
Normal file
2
man/dircolors.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/du.x
Normal file
2
man/du.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
382
man/help2man
Executable file
382
man/help2man
Executable file
@@ -0,0 +1,382 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# Generate a short man page from --help and --version output.
|
||||
# Copyright © 1997, 98 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
# Written by Brendan O'Dea <bod@compusol.com.au>
|
||||
# and François Pinard <pinard@IRO.UMontreal.CA>
|
||||
|
||||
require 5.003;
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use POSIX 'strftime';
|
||||
|
||||
my $RCS_Id = '$Id: help2man,v 1.1 1998/09/09 13:47:43 meyering Exp $';
|
||||
my $this_program = 'help2man';
|
||||
my $this_version = '0.0';
|
||||
|
||||
if ($RCS_Id =~ /\$Id:\s+(\S+)\s+(\S+)/)
|
||||
{
|
||||
$this_version = $2;
|
||||
($this_program = $1) =~ s/(\.\w+)?,v$//;
|
||||
}
|
||||
|
||||
my $version_info = <<EOT;
|
||||
$this_program $this_version
|
||||
|
||||
Copyright (C) 1997, 98 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
EOT
|
||||
|
||||
my $help_info = <<EOT;
|
||||
`$this_program' generates a man page out of `--help' and `--version' output.
|
||||
|
||||
Usage: $this_program [OPTION]... EXECUTABLE
|
||||
|
||||
--name=STRING use `STRING' as the description for the NAME paragraph
|
||||
--include=FILE include material from `FILE'
|
||||
--opt-include=FILE include material from `FILE' if it exists
|
||||
--output=FILE send output to `FILE'
|
||||
--help print this help, then exit
|
||||
--version print $this_program program version number, then exit
|
||||
|
||||
EXECUTABLE should accept `--help' and `version' options.
|
||||
EOT
|
||||
|
||||
my ($include, $opt_name, $opt_include, $opt_output, $opt_help,
|
||||
$opt_version);
|
||||
|
||||
# Parse options.
|
||||
GetOptions (
|
||||
'name=s' => \$opt_name,
|
||||
'include=s' => \$include,
|
||||
'opt-include=s' => \$opt_include,
|
||||
'output=s' => \$opt_output,
|
||||
help => sub { print $help_info; exit },
|
||||
version => sub { print $version_info; exit },
|
||||
) or die $help_info;
|
||||
|
||||
die $help_info unless @ARGV == 1;
|
||||
|
||||
my %include = ();
|
||||
my @include = (); # to retain order
|
||||
|
||||
# Process include file (if given). Format is:
|
||||
#
|
||||
# [section name]
|
||||
# verbatim text
|
||||
|
||||
if ($include or $opt_include)
|
||||
{
|
||||
if (open INC, $include || $opt_include)
|
||||
{
|
||||
my $sect;
|
||||
|
||||
while (<INC>)
|
||||
{
|
||||
if (/^\[([^]]+)\]/)
|
||||
{
|
||||
$sect = uc $1;
|
||||
$sect =~ s/^\s+//;
|
||||
$sect =~ s/\s+$//;
|
||||
next;
|
||||
}
|
||||
|
||||
# Silently ignore anything before the first
|
||||
# section--allows for comments and revision info.
|
||||
next unless $sect;
|
||||
|
||||
push @include, $sect unless $include{$sect};
|
||||
$include{$sect} ||= '';
|
||||
$include{$sect} .= $_;
|
||||
}
|
||||
|
||||
close INC;
|
||||
|
||||
die "$this_program: no valid information found in `$include'\n"
|
||||
unless %include;
|
||||
|
||||
# Compress trailing blank lines
|
||||
for (keys %include)
|
||||
{
|
||||
$include{$_} =~ s/\n+$//;
|
||||
$include{$_} .= "\n" unless /^NAME$/;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
die "$this_program: can't open `$include' ($!)\n" if $include;
|
||||
}
|
||||
}
|
||||
|
||||
# Turn off localisation of executable's ouput.
|
||||
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
|
||||
|
||||
# Grab help and version paragraphs from executable
|
||||
my @help = split /\n\n+/, `$ARGV[0] --manhelp 2>/dev/null`;
|
||||
my @version = split /\n\n+/, `$ARGV[0] --version 2>/dev/null`
|
||||
or die "$this_program: can't get `--version' info from $ARGV[0]\n";
|
||||
|
||||
@help = split /\n\n+/, `$ARGV[0] --help 2>/dev/null`
|
||||
or die "$this_program: can't get `--help' info from $ARGV[0]\n"
|
||||
unless @help;
|
||||
|
||||
my $date = strftime "%B %Y", localtime;
|
||||
(my $program = $ARGV[0]) =~ s!.*/!!;
|
||||
my $package = $program;
|
||||
my $version;
|
||||
|
||||
if ($opt_output)
|
||||
{
|
||||
unlink $opt_output
|
||||
or die "$this_program: can't unlink $opt_output ($!)\n"
|
||||
if -e $opt_output;
|
||||
|
||||
open STDOUT, ">$opt_output"
|
||||
or die "$this_program: can't create $opt_output ($!)\n";
|
||||
}
|
||||
|
||||
# The first line of the --version information is assumed to be in one
|
||||
# of the following formats:
|
||||
#
|
||||
# <version>
|
||||
# <program> <version>
|
||||
# GNU <program> <version>
|
||||
# <program> (GNU <package>) <version>
|
||||
# <program> - GNU <package> <version>
|
||||
#
|
||||
# and seperated from any copyright/author details by a blank line.
|
||||
|
||||
$_ = shift @version;
|
||||
|
||||
if (/^(\S+)\s+\((GNU\s+[^)]+)\)\s+(.*)/ or
|
||||
/^(\S+)\s+-\s*(GNU\s+\S+)\s+(.*)/)
|
||||
{
|
||||
$program = $1;
|
||||
$package = $2;
|
||||
$version = $3;
|
||||
}
|
||||
elsif (/^(GNU\s+)?(\S+)\s+(.*)/)
|
||||
{
|
||||
$program = $2;
|
||||
$package = $1 ? "$1$2" : $2;
|
||||
$version = $3;
|
||||
}
|
||||
else
|
||||
{
|
||||
$version = $_;
|
||||
}
|
||||
|
||||
$program =~ s!.*/!!;
|
||||
|
||||
# Check for name in help output
|
||||
if ($help[0] =~ s/^(?:name|oneliner):\s*(\S.*)//)
|
||||
{
|
||||
($include{NAME} = "$program \\- $1") =~ s/\s+$//;
|
||||
shift @help unless length $help[0];
|
||||
}
|
||||
|
||||
# --name overrides --include contents and/or --manhelp oneliner
|
||||
$include{NAME} = "$program \\- $opt_name" if $opt_name;
|
||||
|
||||
# Default (useless) NAME paragraph
|
||||
$include{NAME} ||= "$program \\- manual page for $program $version";
|
||||
|
||||
# Man pages traditionally have the page title in caps.
|
||||
my $PROGRAM = uc $program;
|
||||
|
||||
# Header.
|
||||
print <<EOT;
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by $this_program $this_version.
|
||||
.TH $PROGRAM 1 "$date" "$package $version" "FSF"
|
||||
.SH NAME
|
||||
$include{NAME}
|
||||
EOT
|
||||
|
||||
my $accumulate = 1;
|
||||
my @description = ();
|
||||
|
||||
sub convert_option;
|
||||
|
||||
# Output converted --help information.
|
||||
for (@help)
|
||||
{
|
||||
chomp;
|
||||
|
||||
if (s/^Usage:\s+\S+\s+(.*)\n?//)
|
||||
{
|
||||
# Turn the usage clause into a synopsis.
|
||||
my $synopsis = '';
|
||||
|
||||
do {
|
||||
my $syn = $1;
|
||||
$syn =~ s/(([][]|\.\.+)+)/\\fR$1\\fI/g;
|
||||
$syn =~ s/^/\\fI/ unless $syn =~ s/^\\fR//;
|
||||
$syn .= '\fR';
|
||||
$syn =~ s/\\fI(\s*)\\fR/$1/g;
|
||||
|
||||
$synopsis .= ".br\n" unless $accumulate;
|
||||
$synopsis .= ".B $program\n";
|
||||
$synopsis .= "$syn\n";
|
||||
$accumulate = 0;
|
||||
} while s/^(?:Usage|\s*or):\s+\S+\s+(.*)\n?//;
|
||||
|
||||
# Include file overrides SYNOPSIS
|
||||
print ".SH SYNOPSIS\n", $include{SYNOPSIS} || $synopsis;
|
||||
|
||||
# Dump any accumulated description text.
|
||||
print ".SH DESCRIPTION\n";
|
||||
print @description;
|
||||
|
||||
# Add additional description text from include file
|
||||
if ($include{DESCRIPTION})
|
||||
{
|
||||
print ".PP\n" unless $include{DESCRIPTION} =~ /^\..P/;
|
||||
print $include{DESCRIPTION};
|
||||
}
|
||||
|
||||
next unless $_;
|
||||
}
|
||||
|
||||
# Accumulate text if the synopsis has not been produced yet.
|
||||
if ($accumulate)
|
||||
{
|
||||
push @description, ".PP\n" if @description;
|
||||
push @description, "$_\n";
|
||||
next;
|
||||
}
|
||||
|
||||
# Catch start of options.
|
||||
if (/^Options:/)
|
||||
{
|
||||
print qq(.SH OPTIONS\n);
|
||||
s/Options://;
|
||||
}
|
||||
|
||||
# Catch bug report text.
|
||||
if (/^Report bugs |^Email bug reports to /)
|
||||
{
|
||||
print qq(.SH "REPORTING BUGS"\n$_\n);
|
||||
next;
|
||||
}
|
||||
|
||||
# Special case for tar 1.12: --label=NAME\nPATTERN.
|
||||
s{(\n[ \t]*)(-V,[ \t]+--label=NAME.*)\n[ \t]+PATTERN[ \t]+}
|
||||
{$1$2$1\\&...=PATTERN };
|
||||
|
||||
# Convert options.
|
||||
s/(\s)(-[][\w=-]+|\\&\S+)/$1 . convert_option $2/ge;
|
||||
|
||||
# Option subsections have second line indented.
|
||||
print qq(.SS "$1"\n) if s/^(\S.*)\n(\s)/$2/;
|
||||
|
||||
# Lines indented more than about 10 spaces may be assumed to be
|
||||
# continuations of the previous line.
|
||||
s/\n {10,}/ /g;
|
||||
|
||||
# Lines following dotted (*) or numbered points may also be
|
||||
# continued if indented to the same level as the text following
|
||||
# the point.
|
||||
1 while s{((?:^|\n)(\s+)(?:[1-9][.)]|\*)(\s+)(?:[^\n]+))\n\2 \3(\S)}
|
||||
{$1 $4}g;
|
||||
|
||||
# Indented paragraph.
|
||||
if (/^\s/)
|
||||
{
|
||||
for (split /\n/)
|
||||
{
|
||||
s/^\s+//;
|
||||
s/([^,])\s+/$1\n/;
|
||||
print ".TP\n$_\n" if $_;
|
||||
}
|
||||
}
|
||||
# Anything else.
|
||||
else
|
||||
{
|
||||
print ".PP\n$_\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Print any include items other than the ones we have already dealt
|
||||
# with.
|
||||
for (@include)
|
||||
{
|
||||
print qq(.SH "$_"\n$include{$_})
|
||||
unless /^(NAME|SYNOPSIS|DESCRIPTION|SEE ALSO)$/;
|
||||
}
|
||||
|
||||
# Refer to the real documentation.
|
||||
if ($include{'SEE ALSO'} or $program ne 'info')
|
||||
{
|
||||
print qq(.SH "SEE ALSO"\n);
|
||||
print $include{'SEE ALSO'}, ".PP\n" if $include{'SEE ALSO'};
|
||||
|
||||
print <<EOT unless $program eq 'info';
|
||||
The full documentation for
|
||||
.B $program
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B $program
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info $program
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
EOT
|
||||
}
|
||||
|
||||
# Output converted --version information.
|
||||
for (@version)
|
||||
{
|
||||
chomp;
|
||||
|
||||
# Convert copyright symbol or (c) to nroff character
|
||||
s/Copyright\s+(?:\xa9|\([Cc]\))/Copyright \\(co/g;
|
||||
|
||||
# Insert appropriate headings for copyright and author
|
||||
if (/^Copyright\s\\/) { print ".SH COPYRIGHT\n" }
|
||||
elsif (/^Written\s+by/) { print ".SH AUTHOR\n" }
|
||||
else { print ".PP\n"; }
|
||||
|
||||
# Insert line breaks before additional copyright messages and the
|
||||
# disclaimer
|
||||
s/(.)\n(Copyright\s|This is free software)/$1\n.br\n$2/g;
|
||||
|
||||
print "$_\n";
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
# Convert option dashes to \- to stop nroff from hyphenating 'em, and
|
||||
# embolden. Option arguments get italicised.
|
||||
sub convert_option
|
||||
{
|
||||
my $option = '\fB' . shift;
|
||||
|
||||
$option =~ s/-/\\-/g;
|
||||
unless ($option =~ s/\[=(.*)\]$/\\fR[=\\fI$1\\fR]/)
|
||||
{
|
||||
$option =~ s/=(.)/\\fR=\\fI$1/;
|
||||
$option =~ s/ (.)/ \\fI$1/;
|
||||
$option .= '\fR';
|
||||
}
|
||||
|
||||
$option;
|
||||
}
|
||||
2
man/install.x
Normal file
2
man/install.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/ln.x
Normal file
2
man/ln.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/ls.x
Normal file
2
man/ls.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/mkdir.x
Normal file
2
man/mkdir.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/mkfifo.x
Normal file
2
man/mkfifo.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/mknod.x
Normal file
2
man/mknod.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/mv.x
Normal file
2
man/mv.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
34
man/rm.x
Normal file
34
man/rm.x
Normal file
@@ -0,0 +1,34 @@
|
||||
[DESCRIPTION]
|
||||
This manual page
|
||||
documents the GNU version of
|
||||
.BR rm .
|
||||
.B rm
|
||||
removes each specified file. By default, it does not remove
|
||||
directories.
|
||||
.P
|
||||
If a file is unwritable, the standard input is a tty, and
|
||||
the \fI\-f\fR or \fI\-\-force\fR option is not given,
|
||||
.B rm
|
||||
prompts the user for whether to remove the file. If the response
|
||||
does not begin with `y' or `Y', the file is skipped.
|
||||
.LP
|
||||
GNU
|
||||
.BR rm ,
|
||||
like every program that uses the getopt function to parse its
|
||||
arguments, lets you use the
|
||||
.I \-\-
|
||||
option to indicate that all following arguments are non-options. To
|
||||
remove a file called `\-f' in the current directory, you could type
|
||||
either
|
||||
.RS
|
||||
rm \-\- \-f
|
||||
.RE
|
||||
or
|
||||
.RS
|
||||
rm ./\-f
|
||||
.RE
|
||||
The Unix
|
||||
.B rm
|
||||
program's use of a single `\-' for this purpose predates the
|
||||
development of the getopt standard syntax.
|
||||
.SH OPTIONS
|
||||
2
man/rmdir.x
Normal file
2
man/rmdir.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/sync.x
Normal file
2
man/sync.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/touch.x
Normal file
2
man/touch.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
2
man/vdir.x
Normal file
2
man/vdir.x
Normal file
@@ -0,0 +1,2 @@
|
||||
[DESCRIPTION]
|
||||
." Add any additional description here
|
||||
@@ -1,3 +1,62 @@
|
||||
1998-09-12 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16x.
|
||||
|
||||
* src/remove.c (remove_cwd_entries): Declare to be static.
|
||||
|
||||
Automatically generate man pages from combination of --help
|
||||
output and the contents of new, man/*.x files.
|
||||
* man/Makefile.am (HELP2MAN): Define.
|
||||
(man_aux): Define.
|
||||
(EXTRA_DIST): Add $(HELP2MAN) and $(man_aux).
|
||||
(MAINTAINERCLEANFILES): Add $(man_MANS).
|
||||
* man/*.x: New files.
|
||||
* man/GNUmakefile: New file.
|
||||
* man/Makefile.maint: New file.
|
||||
* man/help2man: New file.
|
||||
|
||||
1998-09-09 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/modechange.c: Protoize.
|
||||
|
||||
1998-09-07 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16w.
|
||||
|
||||
* src/df.c (show_dev) [!posix_format]: When using --print-type,
|
||||
let the device path and the file system type share a single (wider)
|
||||
field if their combined lengths allow it. From Andries Brouwer.
|
||||
|
||||
* tests/touch/empty-file: Upon failure, suggest how to rerun the test
|
||||
with longer delay, in case NFS clock skew was the cause of the failure.
|
||||
Reported by Kaveh Ghazi.
|
||||
|
||||
* tests/ls-2/quoting: Add tests.
|
||||
* tests/Fetish.pm (run_tests): Add simple PRE/POST hooks.
|
||||
(_create_file): Don't include $$ in temp file name.
|
||||
(run_tests): Use shorter suffixes for temp file names.
|
||||
|
||||
1998-09-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/touch.c: Include posixtm.h.
|
||||
(usage): Correct the description of the format of the
|
||||
date string argument to -t option.
|
||||
(main): Update to use rewritten posixtime function.
|
||||
Reported by Andries Brouwer.
|
||||
|
||||
* lib/Makefile.am (libfu_a_SOURCES): Change posixtm.y to posixtm.c.
|
||||
(noinst_HEADERS): Add posixtm.h.
|
||||
|
||||
* lib/posixtm.h: New file.
|
||||
* lib/posixtm.c: New file. Rewritten based on posixtm.y.
|
||||
* lib/posixtm.y: Remove file.
|
||||
|
||||
1998-09-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* src/ls.c (print_dir_name): Put back.
|
||||
(print_dir): Also print directory name header if print_dir_name is
|
||||
true.
|
||||
|
||||
1998-08-29 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 3.16v.
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
Changes in release 3.17:
|
||||
[3.16x]
|
||||
* man pages are now automatically generated from a combination of --help
|
||||
output and the contents of new (though mostly empty), man/*.x files.
|
||||
[3.16w]
|
||||
* touch now interprets `-t TIME-DATE' as POSIX specifies
|
||||
* `ls EMPTY-DIR EMPTY-DIR' once again outputs the directory names
|
||||
[3.16v]
|
||||
* portability fixes
|
||||
* `ls -R EMPTY-DIR' now outputs the name of the directory
|
||||
|
||||
26
src/df.c
26
src/df.c
@@ -246,15 +246,29 @@ show_dev (const char *disk, const char *mount_point, const char *fstype,
|
||||
|
||||
if (! disk)
|
||||
disk = "-"; /* unknown */
|
||||
|
||||
printf ((print_type ? "%-13s" : "%-20s"), disk);
|
||||
if ((int) strlen (disk) > (print_type ? 13 : 20) && !posix_format)
|
||||
printf ((print_type ? "\n%13s" : "\n%20s"), "");
|
||||
|
||||
if (! fstype)
|
||||
fstype = "-"; /* unknown */
|
||||
|
||||
/* df.c reserved 5 positions for fstype,
|
||||
but that does not suffice for type iso9660 */
|
||||
if (print_type)
|
||||
printf (" %-5s ", fstype);
|
||||
{
|
||||
int disk_name_len = (int) strlen (disk);
|
||||
int fstype_len = (int) strlen (fstype);
|
||||
if (disk_name_len + fstype_len + 2 < 20)
|
||||
printf ("%s%*s ", disk, 18 - disk_name_len, fstype);
|
||||
else if (!posix_format)
|
||||
printf ("%s\n%18s ", disk, fstype);
|
||||
else
|
||||
printf ("%s %s", disk, fstype);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((int) strlen (disk) > 20 && !posix_format)
|
||||
printf ("%s\n%20s", disk, "");
|
||||
else
|
||||
printf ("%-20s", disk);
|
||||
}
|
||||
|
||||
if (inode_format)
|
||||
{
|
||||
|
||||
12
src/ls.c
12
src/ls.c
@@ -474,6 +474,10 @@ static int tabsize;
|
||||
|
||||
static int dir_defaulted;
|
||||
|
||||
/* Nonzero means print each directory name before listing it. */
|
||||
|
||||
static int print_dir_name;
|
||||
|
||||
/* The line length to use for breaking lines in many-per-line format.
|
||||
Can be set with -w. */
|
||||
|
||||
@@ -683,6 +687,7 @@ main (int argc, char **argv)
|
||||
|
||||
exit_status = 0;
|
||||
dir_defaulted = 1;
|
||||
print_dir_name = 1;
|
||||
pending_dirs = 0;
|
||||
current_time = time ((time_t *) 0);
|
||||
|
||||
@@ -753,6 +758,8 @@ main (int argc, char **argv)
|
||||
if (pending_dirs)
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
else if (pending_dirs && pending_dirs->next == 0)
|
||||
print_dir_name = 0;
|
||||
|
||||
while (pending_dirs)
|
||||
{
|
||||
@@ -763,6 +770,7 @@ main (int argc, char **argv)
|
||||
if (thispend->realname)
|
||||
free (thispend->realname);
|
||||
free (thispend);
|
||||
print_dir_name = 1;
|
||||
}
|
||||
|
||||
if (dired && format == long_format)
|
||||
@@ -1581,8 +1589,10 @@ print_dir (const char *name, const char *realname)
|
||||
contents listed rather than being mentioned here as files. */
|
||||
|
||||
if (trace_dirs)
|
||||
extract_dirs_from_files (name, 1);
|
||||
|
||||
if (trace_dirs || print_dir_name)
|
||||
{
|
||||
extract_dirs_from_files (name, 1);
|
||||
DIRED_INDENT ();
|
||||
PUSH_CURRENT_DIRED_POS (&subdired_obstack);
|
||||
dired_pos += quote_name (stdout, realname ? realname : name,
|
||||
|
||||
@@ -425,7 +425,7 @@ same_file (const char *file_1, const char *file_2)
|
||||
/* Recursively remove all of the entries in the current directory.
|
||||
Return an indication of the success of the operation. */
|
||||
|
||||
enum RM_status
|
||||
static enum RM_status
|
||||
remove_cwd_entries (const struct rm_options *x)
|
||||
{
|
||||
/* NOTE: this is static. */
|
||||
|
||||
29
src/touch.c
29
src/touch.c
@@ -15,21 +15,7 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Options:
|
||||
-a, --time={atime,access,use} Change access time only.
|
||||
-c, --no-create Do not create files that do not exist.
|
||||
-d, --date=TIME Specify time and date in various formats.
|
||||
-f Ignored.
|
||||
-m, --time={mtime,modify} Change modification time only.
|
||||
-r, --reference=FILE Use the time and date of reference file FILE.
|
||||
-t TIME Specify time and date in the form
|
||||
`MMDDhhmm[[CC]YY][.ss]'.
|
||||
|
||||
If no options are given, -am is the default, using the current time.
|
||||
The -r, -t, and -d options are mutually exclusive. If a file does not
|
||||
exist, create it unless -c is given.
|
||||
|
||||
Written by Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie,
|
||||
/* Written by Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie,
|
||||
and Randy Smith. */
|
||||
|
||||
#include <config.h>
|
||||
@@ -43,12 +29,12 @@
|
||||
#include "argmatch.h"
|
||||
#include "getdate.h"
|
||||
#include "safe-read.h"
|
||||
#include "posixtm.h"
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
time_t time ();
|
||||
#endif
|
||||
|
||||
time_t posixtime ();
|
||||
int full_write ();
|
||||
void invalid_arg ();
|
||||
|
||||
@@ -214,6 +200,8 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("Usage: %s [OPTION]... FILE...\n"), program_name);
|
||||
printf (_(" or : %s [-acm] MMDDhhmm[YY] FILE... (obsolescent)\n"),
|
||||
program_name);
|
||||
printf (_("\
|
||||
Update the access and modification times of each FILE to the current time.\n\
|
||||
\n\
|
||||
@@ -223,12 +211,14 @@ Update the access and modification times of each FILE to the current time.\n\
|
||||
-f (ignored)\n\
|
||||
-m change only the modification time\n\
|
||||
-r, --reference=FILE use this file's times instead of current time\n\
|
||||
-t STAMP use MMDDhhmm[[CC]YY][.ss] instead of current time\n\
|
||||
-t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time\n\
|
||||
--time=WORD access -a, atime -a, mtime -m, modify -m, use -a\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
STAMP may be used without -t if none of -drt, nor --, are used.\n\
|
||||
Note that the three time-date formats recognized for the -d and -t options\n\
|
||||
and for the obsolescent argument are all different.\n\
|
||||
"));
|
||||
puts (_("\nReport bugs to <fileutils-bugs@gnu.org>."));
|
||||
close_stdout ();
|
||||
@@ -288,7 +278,8 @@ main (int argc, char **argv)
|
||||
|
||||
case 't':
|
||||
posix_date++;
|
||||
newtime = posixtime (optarg);
|
||||
newtime = posixtime (optarg,
|
||||
PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS);
|
||||
if (newtime == (time_t) -1)
|
||||
error (1, 0, _("invalid date format `%s'"), optarg);
|
||||
date_set++;
|
||||
@@ -338,7 +329,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (!date_set && optind < argc && !STREQ (argv[optind - 1], "--"))
|
||||
{
|
||||
newtime = posixtime (argv[optind]);
|
||||
newtime = posixtime (argv[optind], PDS_TRAILING_YEAR);
|
||||
if (newtime != (time_t) -1)
|
||||
{
|
||||
optind++;
|
||||
|
||||
@@ -12,12 +12,12 @@ use FileHandle;
|
||||
use File::Compare qw(compare);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
($VERSION = '$Revision: 1.1 $ ') =~ tr/[0-9].//cd;
|
||||
($VERSION = '$Revision: 1.3 $ ') =~ tr/[0-9].//cd;
|
||||
@EXPORT = qw (run_tests);
|
||||
|
||||
my @Types = qw (IN OUT ERR EXIT);
|
||||
my @Types = qw (IN OUT ERR EXIT PRE POST);
|
||||
my %Types = map {$_ => 1} @Types;
|
||||
my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT);
|
||||
my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT PRE POST);
|
||||
my $srcdir = $ENV{srcdir};
|
||||
my $Global_count = 1;
|
||||
|
||||
@@ -73,7 +73,7 @@ sub _create_file ($$$$)
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = "$test_name-$$.$Global_count";
|
||||
$file = "$test_name.$Global_count";
|
||||
++$Global_count;
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ sub run_tests ($$$$$)
|
||||
{
|
||||
my $test_name = shift @$t;
|
||||
my $expect = {};
|
||||
my ($pre, $post);
|
||||
|
||||
# FIXME: maybe don't reset this.
|
||||
$Global_count = 1;
|
||||
@@ -156,6 +157,12 @@ sub run_tests ($$$$$)
|
||||
die "$program_name: $test_name: more than one $type spec\n"
|
||||
if $Zero_one_type{$type} and $seen_type{$type}++;
|
||||
|
||||
if ($type eq 'PRE' or $type eq 'POST')
|
||||
{
|
||||
$expect->{$type} = $val;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($type eq 'EXIT')
|
||||
{
|
||||
die "$program_name: $test_name: invalid EXIT code\n"
|
||||
@@ -229,9 +236,10 @@ sub run_tests ($$$$$)
|
||||
# in OUT or ERR spec?
|
||||
|
||||
warn "$test_name...\n" if $verbose;
|
||||
&{$expect->{PRE}} if $expect->{PRE};
|
||||
my %tmp;
|
||||
$tmp{OUT} = "$test_name-out";
|
||||
$tmp{ERR} = "$test_name-err";
|
||||
$tmp{OUT} = "$test_name.O";
|
||||
$tmp{ERR} = "$test_name.E";
|
||||
push @junk_files, $tmp{OUT}, $tmp{ERR};
|
||||
my @cmd = ($prog, @args, "> $tmp{OUT}", "2> $tmp{ERR}");
|
||||
my $cmd_str = join ' ', @cmd;
|
||||
@@ -242,7 +250,7 @@ sub run_tests ($$$$$)
|
||||
warn "$program_name: test $test_name failed: command failed:\n"
|
||||
. " `$cmd_str': $!\n";
|
||||
$fail = 1;
|
||||
next;
|
||||
goto cleanup;
|
||||
}
|
||||
$rc >>= 8 if $rc > 0x80;
|
||||
if ($expect->{EXIT} != $rc)
|
||||
@@ -250,7 +258,7 @@ sub run_tests ($$$$$)
|
||||
warn "$program_name: test $test_name failed: exit status mismatch:"
|
||||
. " expected $expect->{EXIT}, got $rc\n";
|
||||
$fail = 1;
|
||||
next;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
foreach $eo (qw (OUT ERR))
|
||||
@@ -263,6 +271,10 @@ sub run_tests ($$$$$)
|
||||
$fail = 1;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
&{$expect->{POST}} if $expect->{POST};
|
||||
|
||||
}
|
||||
|
||||
# FIXME: maybe unlink files inside the big foreach loop?
|
||||
|
||||
@@ -7,6 +7,9 @@ use strict;
|
||||
# Turn off localisation of executable's ouput.
|
||||
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
|
||||
|
||||
my $mkdir = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"}};
|
||||
my $rmdir = {POST => sub {rmdir 'd' or die "d: $!\n"}};
|
||||
|
||||
my $q_bell = {IN => {"q\a" => ''}};
|
||||
my @Tests =
|
||||
(
|
||||
@@ -23,9 +26,13 @@ my @Tests =
|
||||
['q-qs-sh-a', '--quoting=shell-always', $q_bell, {OUT => "'q\a'\n"}],
|
||||
['q-qs-c', '--quoting=c', $q_bell, {OUT => "\"q\\a\"\n"}],
|
||||
['q-qs-esc', '--quoting=escape', $q_bell, {OUT => "q\\a\n"}],
|
||||
|
||||
['emptydir', 'd', {OUT => ''}, $mkdir, $rmdir],
|
||||
['emptydir-x2', 'd d', {OUT => "d:\n\nd:\n"}, $mkdir, $rmdir],
|
||||
['emptydir-R', '-R d', {OUT => "d:\n"}, $mkdir, $rmdir],
|
||||
);
|
||||
|
||||
my $save_temps = 0;
|
||||
my $save_temps = $ENV{SAVE_TEMPS};
|
||||
my $verbose = $ENV{VERBOSE};
|
||||
|
||||
my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
|
||||
|
||||
@@ -12,6 +12,11 @@ if test "$VERBOSE" = yes; then
|
||||
$TOUCH --version
|
||||
fi
|
||||
|
||||
DEFAULT_SLEEP_SECONDS=2
|
||||
SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS}
|
||||
|
||||
fail=0
|
||||
|
||||
# FIXME: find writable directories on other partitions
|
||||
# and run the test in those directories, too.
|
||||
|
||||
@@ -32,14 +37,14 @@ if test $framework_failure = 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
sleep $SLEEP_SECONDS
|
||||
for d in $TOUCH_DIR_LIST; do
|
||||
$TOUCH $d/a || fail=1
|
||||
set x `$LS -t $d/a $d/b`
|
||||
test "$*" = "x $d/a $d/b" || fail=1
|
||||
done
|
||||
|
||||
sleep 2
|
||||
sleep $SLEEP_SECONDS
|
||||
for d in $TOUCH_DIR_LIST; do
|
||||
$TOUCH $d/b
|
||||
set x `$LS -t $d/a $d/b`
|
||||
@@ -48,4 +53,14 @@ for d in $TOUCH_DIR_LIST; do
|
||||
$RM -rf $d/a $d/b
|
||||
done
|
||||
|
||||
if test $fail != 0; then
|
||||
cat 1>&2 <<EOF
|
||||
*** This test has just failed. That can happen when the test is run in an
|
||||
*** NFS-mounted directory on a system whose clock is not well synchronized
|
||||
*** with that of the NFS server. If you think that is the reason, set the
|
||||
*** environment variable SLEEP_SECONDS to some number of seconds larger than
|
||||
*** the default of $DEFAULT_SLEEP_SECONDS and rerun the test.
|
||||
EOF
|
||||
fi
|
||||
|
||||
exit $fail
|
||||
|
||||
Reference in New Issue
Block a user