CFLAGS = @CFLAGS@
YACC = @YACC@
+prefix = /usr/local
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+
SOURCES = getdate.y posixtm.y \
argmatch.c backupfile.c basename.c dirname.c eaccess.c \
error.c filemode.c fsusage.c getopt.c getopt1.c \
+Thu Oct 07 12:57:10 1993 Jim Meyering (meyering@comco.com)
+
+ * chgrp.c, chmod.c, chown.c, cp-aux.c, cp.c, dd.c, df.c, du.c,
+ install.c, ln.c, ls.c, mkdir.c, mkfifo.c, mknod.c, mv.c, mvdir.c,
+ rm.c, rmdir.c, touch.c (usage): Using --help gets long well-
+ formatted help. Now --help writes to stdout and exits successfully.
+ From Francois Pinard <pinard@iro.umontreal.ca>.
+
+ * lib/Makefile.in [libdir]: Make sure it's defined.
+
+ * posixtm.y [!__GNUC__ && !HAVE_ALLOCA_H]: Declare alloca as void*
+ rather than char*. The latter conflicts with a dcl from bison.simple.
+
Wed Oct 06 18:22:00 1993 Jim Meyering (meyering@comco.com)
* chmod.c (change_file_mode): Add an argument to control how symbolic
Fri Jul 16 22:00:16 1993 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu)
* dd.c (print_stats): Change message from "truncated blocks"
- to "truncated records" for final POSIX.2 spec.
+ to "truncated records" for final POSIX.2 spec.
Fri Jun 25 17:18:15 1993 Jim Meyering (meyering@comco.com)
* src/Makefile.in (install): Rewrite the test for whether to install
mvdir so that it doesn't cause gratuitous failures with broken shells.
- Split long rule so the pieces fit in 80-column lines.
+ Split long rule so the pieces fit in 80-column lines.
Thu Apr 15 23:44:01 1993 Jim Meyering (meyering@comco.com)
whether to do it once per buffer read, instead of once per character.
(copy): If conv=block and the input didn't end with a newline,
pad the final block with spaces.
-
+
Wed Mar 25 14:35:17 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu)
* system.h: Don't use BSIZE for calculating ST_BLKSIZE if it
* df.c, fsinfo.c, fsinfo.h: New program.
* configure: Check for various ways of getting info on mounted
- filesystems.
+ filesystems.
Thu Aug 22 10:53:23 1991 David J. MacKenzie (djm at apple-gunkies)
* configure: echo messages to stdout, not stderr.
Use test programs to see if alloca needs -lPW and if chars are
- unsigned.
+ unsigned.
Tue Jul 2 03:16:32 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
* backupfile.c: Use POSIX instead of _POSIX_SOURCE to
determine whether to check whether readdir returned a valid
- entry.
+ entry.
Fri Jun 7 21:44:51 1991 David J. MacKenzie (djm at geech.gnu.ai.mit.edu)
* dd.c (copy): Only seek if not seeking to start of file, so
"dd >> foo" works with Minix shell that doesn't open foo in
- append mode.
+ append mode.
Thu Feb 21 11:59:39 1991 David J. MacKenzie (djm at geech.ai.mit.edu)
Fri Dec 28 18:40:34 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
* chmod.c, chown.c, chgrp.c, du.c: Rename -d option to -L for
- similarity to ls and cpio.
+ similarity to ls and cpio.
Thu Dec 27 00:06:45 1990 David J. MacKenzie (djm at egypt)
* rm.c (check_stack): If not interactive, don't prompt when
corruption is found, just quit.
(remove_file, remove_dir): Delete leading spaces in verbose
- output.
+ output.
* cp.c (copy), rm.c (remove_dir): If we think the dest. file
is unwritable, warn the user in the interactive prompt instead
* du.c: Rename -f option to -x, for POSIX. Rename
+kilobyte-file-size to +kilobytes. Add -b, +bytes option for
- POSIX.
+ POSIX.
* cp-aux.c (usage): Change -o to -x.
(stpcpy): Renamed from str_cpy. Change callers in cp.c.
Mon Jul 23 16:57:44 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
- * cp.c (copy): Make +update operate silently, like +one-file-system.
+ * cp.c (copy): Make +update operate silently, like +one-file-system.
* ln.c: Add -F as synonym for -d, for SunOS compatibility.
* rm.c (main, usage): Add new option -d, +directory.
(rm): If -d given, use remove_file instead of remove_dir for
- directories.
+ directories.
(remove_file): If directory, print "remove directory `foo'?"
for interactive instead of "remove `foo'?".
default owner and group.
* mv.c (main): New option -u, +update.
- (do_move): Don't move nondirectories if -u and there is an existing
+ (do_move): Don't move nondirectories if -u and there is an existing
destination that has the same or newer mtime.
(usage): Document -u, +update.
* cp.c (main): New option -u, +update.
- (copy): Don't copy nondirectories if -u and there is an existing
+ (copy): Don't copy nondirectories if -u and there is an existing
destination that has the same or newer mtime.
* cp-aux.c (usage): Document -u ,+update.
* rm.c, rmdir.c, mkdir.c, mkfifo.c: Move code to remove
slashes at the end of an arg from main to
- strip_trailing_slashes.
+ strip_trailing_slashes.
* install.c (strip): Print error message if the `strip'
program can't be run.
Thu Jun 21 01:19:28 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
- * ls.c (print_long_format): Use mode_string instead of filemodestring.
+ * ls.c (print_long_format): Use mode_string instead of filemodestring.
* ls.c (print_long_format): Compare times as longs, not ints.
(longdiff): Macro to compare two longs efficiently if sizeof
Sat Jun 16 01:45:42 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
* argmatch.c (invalid_arg): Change order in which the items
- are printed.
+ are printed.
* ls.c: Add +tabsize (-T) option.
* mv.c (usage), ln.c (usage), cp-aux.c (usage): Revise messages.
* chmod.c (describe_change): Use mode_string instead of
- filemodestring.
+ filemodestring.
* cp.c (main): Recognize new options for making backups.
* cp.c (copy): Make backups if requested. Fix typo.
* dd.c: Make translation tables unsigned.
(main): Give `input_file' and `output_file' nonzero values for
- stdin and stdout.
+ stdin and stdout.
(parse_conversion): Set new global vars 'space_character' and
'newline_character' to correct values when translating to EBCDIC
(either flavor).
Sat May 12 01:16:42 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
* cp-hash (remember_created): Return error status instead of
- fatal error.
+ fatal error.
* cp.c (copy): Change caller.
(do_copy, copy_reg): Return error status instead of fatal error.
Fri May 11 02:11:03 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
* ln.c, mv.c, rm.c, rmdir.c, create.c, chmod.c: Change some
- error messages.
+ error messages.
* du.c, cp-aux.c (error): Function removed.
Change callers to use error.c version.
* ls.c (main): Don't remove leading path from program_name.
(basename): Function removed.
(length_of_file_name_and_frills): Don't add 1 for type indicator
- for block and character special files.
+ for block and character special files.
Thu Apr 12 19:50:15 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
* rm.c (remove_file): Ditto.
(remove_dir): Use eaccess_stat to determine readability and
searchability. Move initial interactive query here from
- clear_directory.
+ clear_directory.
* Makefile: Link ln, mv, and rm with eaccess.o.
Sat Apr 7 11:47:52 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
Sat Mar 31 22:29:57 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
* mv.c [RENAME_MISSING] (rename): To rename directories, run
- setuid root mv_dir program.
+ setuid root mv_dir program.
Tue Mar 20 14:28:25 1990 David J. MacKenzie (djm at pogo.ai.mit.edu)
* cp-aux.c, cp.h: Rename user_confirm_overwriting to yesno and
don't have it print a prompt, so it can be used in several
- places.
+ places.
* cp.c (do_copy): Change an error message to resemble mv's.
Remove all trailing slashes from all non-option args.
(main): Set new global var `stdin_not_tty'.
(copy): Use POSIX method of handling file overwriting and
- prompting.
+ prompting.
* dirlib.c (mkdir): Use chmod to set the directory mode after
successful creation, so set[ug]id and sticky bits are set
- correctly.
+ correctly.
Thu Mar 15 12:33:23 1990 David J. MacKenzie (djm at albert.ai.mit.edu)
Global: Call error instead of the above functions.
(change_dir_mode): Make the new size of the path twice the
size of the name that was too long, rather than twice its old
- size.
+ size.
* rm.c: Move interactive query about whether to remove a
directory from remove_dir to clear_directory; only query for
* Makefile (CC): Add comment noting that either fixincludes or
-traditional needs to be used for gcc to compile ioctl calls
- correctly.
+ correctly.
Mon Mar 12 16:25:23 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu)
(do_move): Simplify check for query. Rename `stb' to
`to_stats' and `stbf' to `from_stats'.
Return error condition if original file could not be renamed or
- unlinked.
+ unlinked.
* rm.c: Rename global `force_flag' to `ignore_errors' and change its
meaning so that it does not overlap with `override_mode'.
* ln.c (main): Reword an error message to be more like mv's.
- * rmdir.c: Move global `errors' into main instead of having
+ * rmdir.c: Move global `errors' into main instead of having
error set it.
* mkdir.c: Move global `errors' into main and have make_path
* du.c (main): Check error return from stat.
(str_copyc, str_concatc): Don't return a value, since it is
- ignored.
+ ignored.
* cp.c (copy): Check error return from unlink and chmod. Fix
typo in call to error.
Major changes in release 3.9:
+* --help gives one-line description of options and shows correspondence
+ between short and long-named options.
* GNU chmod treats symlinks the same way other vendor's versions do.
Now symlinks listed on the command line are processed (they were
ignored before); the permissions of the dereferenced files are
verbose = 1;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (optind >= argc - 1)
- usage ();
+ usage (1);
parse_group (argv[optind++], &group);
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-Rcfv] [--recursive] [--changes] [--silent] [--quiet]\n\
- [--verbose] [--help] [--version] group file...\n",
+Usage: %s [OPTION]... GROUP FILE...\n\
+\n",
program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -c, --changes be verbose whenever change occurs\n\
+ -f, --silent, --quiet avoid most error messages\n\
+ -v, --verbose explain what is being done\n\
+ -R, --recursive change files and directories recursively\n\
+ --help provide this help\n\
+ --version show program version\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
verbose = 1;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (modeind == 0)
modeind = optind++;
if (optind >= argc)
- usage ();
+ usage (1);
changes = mode_compile (argv[modeind],
MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS);
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-Rcfv] [--recursive] [--changes] [--silent] [--quiet]\n\
- [--verbose] [--help] [--version] mode file...\n\
- mode is [ugoa...][[+-=][rwxXstugo...]...][,...] or octal number\n",
- program_name);
- exit (1);
+Usage: %s [OPTION]... MODE[,MODE]... FILE...\n\
+ or: %s [OPTION]... OCTAL_MODE FILE...\n\
+\n",
+ program_name, program_name);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -c, --changes be verbose whenever change occurs\n\
+ -f, --silent, --quiet avoid most error messages\n\
+ -v, --verbose explain what is being done\n\
+ -R, --recursive change files and directories recursively\n\
+ --help provide this help\n\
+ --version show program version\n\
+\n\
+Each MODE is one or more of letters ugoa, one of the signs +-= and one\n\
+or more of letters rwxXstugo.\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/*
+/*
| user
| unchanged explicit
-------------|-------------------------+-------------------------|
verbose = 1;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (optind >= argc - 1)
- usage ();
+ usage (1);
e = parse_user_spec (argv[optind], &user, &group, &username, &groupname);
if (e)
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-Rcfv] [--recursive] [--changes] [--silent] [--quiet]\n\
- [--verbose] [--help] [--version] [user][:.][group] file...\n",
- program_name);
- exit (1);
+Usage: %s [OPTION]... OWNER[.[GROUP]] FILE...\n\
+ or: %s [OPTION]... .[GROUP] FILE...\n\
+\n",
+ program_name, program_name);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -c, --changes be verbose whenever change occurs\n\
+ -f, --silent, --quiet avoid most error messages\n\
+ -v, --verbose explain what is being done\n\
+ -R, --recursive change files and directories recursively\n\
+ --help provide this help\n\
+ --version show program version\n\
+\n\
+Owner is unchanged if missing. Group is unchanged is missing, but changed\n\
+to login group if implied by a period. A colon may replace the period.\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
break;
default:
- usage ((char *) 0);
+ usage ((char *) 0, 2);
}
}
}
if (show_help)
- usage (NULL);
+ usage (NULL, 0);
if (flag_hard_link && flag_symbolic_link)
- usage ("cannot make both hard and symbolic links");
+ usage ("cannot make both hard and symbolic links", 2);
if (make_backups)
backup_type = get_version (version);
int ret = 0;
if (optind >= argc)
- usage ("missing file arguments");
+ usage ("missing file arguments", 2);
if (optind >= argc - 1)
- usage ("missing file argument");
+ usage ("missing file argument", 2);
dest = argv[argc - 1];
{
ret |= copy (arg, dst_path, new_dst, 0, (struct dir_list *) 0);
forget_all ();
-
+
if (flag_path)
{
ret |= re_protect (dst_path, strlen (dest) + 1,
struct stat source_stats;
if (flag_path)
- usage ("when preserving paths, last argument must be a directory");
+ usage ("when preserving paths, last argument must be a directory", 2);
source = argv[optind];
return copy (source, new_dest, new_dst, 0, (struct dir_list *) 0);
}
else
- usage ("when copying multiple files, last argument must be a directory");
+ usage ("when copying multiple files, last argument must be a directory",
+ 2);
}
\f
/* Copy the file SRC_PATH to the file DST_PATH. The files may be of
src = dirpath + src_offset;
- tmp_dst_dirname = dirname (dirpath);
+ tmp_dst_dirname = dirname (dirpath);
dst_dirname = (char *) alloca (strlen (tmp_dst_dirname) + 1);
strcpy (dst_dirname, tmp_dst_dirname);
free (tmp_dst_dirname);
dst_path = (char *) alloca (strlen (const_dst_path) + 1);
strcpy (dst_path, const_dst_path);
- src_path = dst_path + src_offset;
+ src_path = dst_path + src_offset;
for (p = attr_list; p; p = p->next)
{
}
if (show_help)
- usage ();
+ usage (0);
apply_translations ();
}
else
output_file = "standard output";
-
+
#ifdef _POSIX_VERSION
sigaction (SIGINT, NULL, &sigact);
if (sigact.sa_handler != SIG_IGN)
nfree = nread;
bcopy (start, obuf + oc, nfree);
-
+
nread -= nfree; /* Update the number of bytes left to copy. */
start += nfree;
oc += nfree;
break;
default:
- usage ();
+ usage (1);
}
}
if (val == NULL)
{
error (0, 0, "unrecognized option `%s'", name);
- usage ();
+ usage (1);
}
*val++ = '\0';
else
{
error (0, 0, "unrecognized option `%s=%s'", name, val);
- usage ();
+ usage (1);
}
}
}
if (conversions[i].convname == NULL)
{
error (0, 0, "%s: invalid conversion", str);
- usage ();
+ usage (1);
}
str = new;
} while (new != NULL);
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [if=file] [of=file] [ibs=bytes] [obs=bytes] [bs=bytes] [cbs=bytes]\n\
- [skip=blocks] [seek=blocks] [count=blocks]\n\
- [conv={ascii,ebcdic,ibm,block,unblock,lcase,ucase,swab,noerror,notrunc,\n\
- sync}] [--help] [--version]\n\
-Numbers can be followed by a multiplier:\n\
-b=512, c=1, k=1024, w=2, xm=number m\n",
+Usage: %s [OPTION]...\n\
+\n",
program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ bs=BYTES force ibs=BYTES and obs=BYTES\n\
+ cbs=BYTES convert BYTES bytes at a time\n\
+ conv=KEYWORDS convert the file as per the comma separated keyword list\n\
+ count=BLOCKS copy only BLOCKS input blocks\n\
+ ibs=BYTES read BYTES bytes at a time\n\
+ if=FILE read from FILE instead of stdin\n\
+ obs=BYTES write BYTES bytes at a time\n\
+ of=FILE write to FILE instead of stdout, don't truncate file\n\
+ seek=BLOCKS skip BLOCKS obs-sized blocks at start of output\n\
+ skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input\n\
+ --help provide this help\n\
+ --version show program version\n\
+\n\
+BYTES may be suffixed: by xM for multiplication by M, by c for x1,\n\
+by w for x2, by b for x512, by k for x1024. Each KEYWORD may be:\n\
+\n\
+ ascii from EBCDIC to ASCII\n\
+ ebcdic from ASCII to EBCDIC\n\
+ ibm from ASCII to alternated EBCDIC\n\
+ block pad newline-terminated records with spaces to cbs-size \n\
+ unblock replace trailing spaces in cbs-size records with newline\n\
+ lcase change uppercase to lowercase\n\
+ ucase change lowercase to uppercase\n\
+ swab swap every pair of input bytes\n\
+ noerror continue after read errors\n\
+ sync pad every input block with NULs to ibs-size\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
add_excluded_fs_type (optarg);
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (optind != argc)
{
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-aikPv] [-t fstype] [-x fstype] [--all] [--inodes]\n\
-\t[--type=fstype] [--exclude-type=fstype] [--kilobytes] [--portability]\n\
-\t[--help] [--version] [path...]\n",
+Usage: %s [OPTION] [PATH]...\n\
+\n",
program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -a, --all include filesystems having 0 blocks\n\
+ -i, --inodes list inode information instead of block usage\n\
+ -k, --kilobytes use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
+ -t, --type TYPE limit the listing to TYPE filesystems type\n\
+ -x, --exclude-type TYPE limit the listing to not TYPE filesystems type\n\
+ -v (ignored)\n\
+ -P, --portability use the POSIX output format\n\
+ --help provide this help\n\
+ --version show program version\n\
+\n\
+If no PATHs are given, list all currently mounted filesystems.\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
};
static void
-usage (reason)
+usage (reason, status)
char *reason;
+ int status;
{
if (reason != NULL)
fprintf (stderr, "%s: %s\n", program_name, reason);
fprintf (stderr, "\
-Usage: %s [-abcklsxDLS] [--all] [--total] [--count-links] [--summarize]\n\
- [--bytes] [--kilobytes] [--one-file-system] [--separate-dirs]\n\
- [--dereference] [--dereference-args] [--help] [--version] [path...]\n",
+Usage: %s [OPTION]... [PATH]...\n\
+\n",
program_name);
- exit (2);
+ if (status == 0)
+ fprintf (stderr, "\
+ -a, --all write counts for all files, not just directories\n\
+ -b, --bytes print size in bytes\n\
+ -c, --total produce a grand total\n\
+ -k, --kilobytes use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
+ -l, --count-links count sizes many times if hard linked\n\
+ -s, --summarize display only a total for each argument\n\
+ -x, --one-file-system skip directories on different filesystems\n\
+ -D, --dereference-args dereference PATHs when symbolic link\n\
+ -L, --dereference dereference all symbolic links\n\
+ -S, --separate-dirs do not include size of subdirectories\n\
+ --help provide this help\n\
+ --version show program version\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
\f
void
break;
default:
- usage ((char *) 0);
+ usage ((char *) 0, 2);
}
}
}
if (show_help)
- usage (NULL);
+ usage (NULL, 0);
if (opt_all && opt_summarize_only)
- usage ("cannot both summarize and show all entries");
+ usage ("cannot both summarize and show all entries", 2);
/* Initialize the hash structure for inode numbers. */
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);
owner_name = optarg;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
/* Check for invalid combinations of arguments. */
if ((dir_arg && strip_files)
|| (optind == argc)
|| (optind == argc - 1 && !dir_arg))
- usage ();
+ usage (1);
if (symbolic_mode)
{
else
{
if (!isdir (argv[argc - 1]))
- usage ();
+ usage (1);
for (; optind < argc - 1; ++optind)
{
errors |= install_file_in_dir (argv[optind], argv[argc - 1]);
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [options] [-s] [--strip] source dest\n\
- %s [options] [-s] [--strip] source... directory\n\
- %s [options] {-d,--directory} directory...\n\
-Options:\n\
- [-c] [-g group] [-m mode] [-o owner] [--group=group]\n\
- [--help] [--version] [--mode=mode] [--owner=owner]\n",
+Usage: %s [OPTION]... SOURCE DEST (1st format)\n\
+ or: %s [OPTION]... SOURCE... DIRECTORY (2nd format)\n\
+ or: %s [OPTION]... DIRECTORY... (3nd format)\n\
+\n",
program_name, program_name, program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -c (ignored)\n\
+ -d, --directory create [leading] directories, mandatory for 3rd format\n\
+ -g, --group GROUP set group ownership, instead of process' current group\n\
+ -m, --mode MODE set permission mode (as in chmod), instead of 0755\n\
+ -o, --owner OWNER set ownership (super-user only)\n\
+ -s, --strip strip symbol tables, only for 1st and 2nd formats\n\
+ --help provide this help\n\
+ --version show program version\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
/* If non-zero, print the version on standard output and exit. */
static int show_version;
-static struct option const long_options[] =
+static struct option const long_options[] =
{
{"backup", no_argument, NULL, 'b'},
{"directory", no_argument, &hard_dir_link, 1},
version = optarg;
break;
default:
- usage ();
+ usage (1);
break;
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (optind == argc)
- usage ();
+ usage (1);
if (make_backups)
backup_type = get_version (version);
error (0, errno, "%s", dest);
return 1;
}
-
+
if (verbose)
printf ("%s -> %s\n", source, dest);
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [options] source [dest]\n\
- %s [options] source... directory\n\
-Options:\n\
- [-bdfisvF] [-S backup-suffix] [-V {numbered,existing,simple}]\n\
- [--version-control={numbered,existing,simple}] [--backup] [--directory]\n\
- [--force] [--interactive] [--symbolic] [--verbose]\n\
- [--suffix=backup-suffix] [--help] [--version]\n",
+Usage: %s [OPTION]... SOURCE [DEST]\n\
+ or: %s [OPTION]... SOURCE... DIRECTORY\n\
+\n",
program_name, program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -b, --backup make backups for removed files\n\
+ -d, -F, --directory hard link directories (super-user only)\n\
+ -f, --force remove existing destinations\n\
+ -i, --interactive prompt whether to remove destinations\n\
+ -s, --symbolic make symbolic links, instead of hard links\n\
+ -v, --verbose print name of each file before linking\n\
+ -S, --suffix SUFFIX override the usual backup suffix\n\
+ -V, --version-control WORD override the usual version control\n\
+ --help provide this help\n\
+ --version show program version\n\
+\n\
+The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The\n\
+version control may be set with VERSION_CONTROL, values are:\n\
+\n\
+ t, numbered make numbered backups\n\
+ nil, existing numbered if numbered backups exist, simple otherwise\n\
+ never, simple always make simple backups \n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
}
if (show_help)
- usage ();
+ usage (0);
format_needs_stat = sort_type == sort_time || sort_type == sort_size
|| format == long_format
all_files = 1;
really_all_files = 1;
break;
-
+
case 'b':
quote_funny_chars = 1;
qmark_funny_chars = 0;
break;
-
+
case 'c':
time_type = time_ctime;
break;
-
+
case 'd':
immediate_dirs = 1;
break;
case 'i':
print_inode = 1;
break;
-
+
case 'k':
kilobyte_blocks = 1;
break;
-
+
case 'l':
format = long_format;
break;
-
+
case 'm':
format = with_commas;
break;
-
+
case 'n':
numeric_users = 1;
break;
-
+
case 'p':
indicator_style = not_programs;
break;
-
+
case 'q':
qmark_funny_chars = 1;
quote_funny_chars = 0;
break;
-
+
case 'r':
sort_reverse = 1;
break;
-
+
case 's':
print_block_size = 1;
break;
-
+
case 't':
sort_type = sort_time;
break;
-
+
case 'u':
time_type = time_atime;
break;
-
+
case 'w':
line_length = atoi (optarg);
if (line_length < 1)
error (1, 0, "invalid line width: %s", optarg);
break;
-
+
case 'x':
format = horizontal;
break;
-
+
case 'A':
all_files = 1;
break;
-
+
case 'B':
add_ignore_pattern ("*~");
add_ignore_pattern (".*~");
break;
-
+
case 'C':
format = many_per_line;
break;
-
+
case 'F':
indicator_style = all;
break;
-
+
case 'G': /* inhibit display of group info */
inhibit_group = 1;
break;
-
+
case 'I':
add_ignore_pattern (optarg);
break;
-
+
case 'L':
trace_links = 1;
break;
-
+
case 'N':
quote_funny_chars = 0;
qmark_funny_chars = 0;
break;
-
+
case 'Q':
quote_as_string = 1;
quote_funny_chars = 1;
qmark_funny_chars = 0;
break;
-
+
case 'R':
trace_dirs = 1;
break;
-
+
case 'S':
sort_type = sort_size;
break;
-
+
case 'T':
tabsize = atoi (optarg);
if (tabsize < 1)
if (i < 0)
{
invalid_arg ("sort type", optarg, i);
- usage ();
+ usage (1);
}
sort_type = sort_types[i];
break;
if (i < 0)
{
invalid_arg ("time type", optarg, i);
- usage ();
+ usage (1);
}
time_type = time_types[i];
break;
if (i < 0)
{
invalid_arg ("format type", optarg, i);
- usage ();
+ usage (1);
}
format = formats[i];
break;
-
+
default:
- usage ();
+ usage (1);
}
}
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-abcdgiklmnpqrstuxABCFGLNQRSUX1] [-w cols] [-T cols] [-I pattern]\n\
- [--all] [--escape] [--directory] [--inode] [--kilobytes] [--literal]\n\
- [--numeric-uid-gid] [--hide-control-chars] [--reverse] [--size]\n\
- [--width=cols] [--tabsize=cols] [--almost-all] [--ignore-backups]\n",
+Usage: %s [OPTION]... [PATH]...\n\
+\n",
program_name);
- fprintf (stderr, "\
- [--classify] [--file-type] [--ignore=pattern] [--dereference]\n\
- [--quote-name] [--recursive] [--sort={none,time,size,extension}]\n\
- [--format={long,verbose,commas,across,vertical,single-column}]\n\
- [--time={atime,access,use,ctime,status}] [--no-group]\n\
- [--help] [--version] [path...]\n");
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -a, --all do not hide entries starting with .\n\
+ -b, --escape print octal escapes for nongraphic characters\n\
+ -c sort by change time, list change time if -l\n\
+ -d, --directory list directory entries, instead of contents\n\
+ -f do not sort, enable -aU, disable -lst\n\
+ -g (ignored)\n\
+ -i, --inode print index number of each file\n\
+ -k, --kilobytes use 1024 blocks, not 512 despite POSIXLY_CORRECT\n\
+ -l make a long listing, with many informations\n\
+ -m fill width with a comma separated list of entries\n\
+ -n, --numeric-uid-gid list numeric UIDs and GIDs, instead of names\n\
+ -p append a character for typing each entry\n\
+ -q, --hide-control-chars print ? instead of non graphic characters\n\
+ -r, --reverse reverse order while sorting\n\
+ -s, --size print block size of each file\n\
+ -t sort by modification time, list mod time if -l\n\
+ -u sort by last access time, list access time if -l\n\
+ -w, --width COLS assume screen width, instead of current value\n\
+ -x list entries by lines, instead of by columns\n\
+ -A, --almost-all hide only implied . and ..\n\
+ -B, --ignore-backups hide implied entries ending with ~\n\
+ -C list entries by columns\n\
+ -F, --classify append a character for typing each entry\n\
+ -G, --no-group inhibit display of group information\n\
+ -I, --ignore PATTERN hide implied entries matching shell PATTERN\n\
+ -L, --dereference list entries pointed to by symbolic links\n\
+ -N, --literal do not quote entry names\n\
+ -Q, --quote-name enclose entry names in double quotes\n\
+ -R, --recursive list subdirectories recursively\n\
+ -S sort by file size\n\
+ -T, --tabsize COLS assume tab stops at each COLS, instead of 8\n\
+ -U do not sort and list entries in directory order\n\
+ -X sort alphabetically by entry extension\n\
+ -1 list one file per line\n\
+ --full-time list both full date and full time\n\
+ --help provide this help\n\
+ --format WORD across -x, commas -m, horizontal -x, long -l,\n\
+ single-column -1, verbose -l, vertical -C\n\
+ --sort WORD ctime -c, extension -X, none -U, size -S,\n\
+ status -c, time -t\n\
+ --time WORD atime -u, access -u, use -u\n\
+ --version show program version\n\
+\n\
+Sort entries alphabetically if none of -cftuSUX nor --sort.\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
symbolic_mode = optarg;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (optind == argc)
- usage ();
+ usage (1);
newmode = 0777 & ~umask (0);
parent_mode = newmode | 0300; /* u+wx */
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-p] [-m mode] [--parents] [--mode=mode]\n\
- [--help] [--version] dir...\n", program_name);
- exit (1);
+Usage: %s [OPTION] DIRECTORY...\n\
+\n",
+ program_name);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -p, --parents no error if existing, make parent directories as needed\n\
+ -m, --mode MODE set permission mode (as in chmod), not 0777 - umask\n\
+ --help provide this help\n\
+ --version show program version\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
symbolic_mode = optarg;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (optind == argc)
- usage ();
+ usage (1);
newmode = 0666 & ~umask (0);
if (symbolic_mode)
#ifdef S_ISFIFO
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-m mode] [--mode=mode] [--help] [--version] path...\n",
+Usage: %s [OPTION] PATH...\n\
+\n",
program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -m, --mode MODE set permission mode (as in chmod), not 0666 - umask\n\
+ --help provide this help\n\
+ --version show program version\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
#endif
symbolic_mode = optarg;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
newmode = 0666 & ~umask (0);
if (symbolic_mode)
}
if (argc - optind != 2 && argc - optind != 4)
- usage ();
+ usage (1);
/* Only check the first character, to allow mnemonic usage like
`mknod /dev/rst0 character 18 0'. */
error (4, 0, "block special files not supported");
#else
if (argc - optind != 4)
- usage ();
+ usage (1);
if (mknod (argv[optind], newmode | S_IFBLK,
makedev (atoi (argv[optind + 2]), atoi (argv[optind + 3]))))
error (1, errno, "%s", argv[optind]);
error (4, 0, "character special files not supported");
#else
if (argc - optind != 4)
- usage ();
+ usage (1);
if (mknod (argv[optind], newmode | S_IFCHR,
makedev (atoi (argv[optind + 2]), atoi (argv[optind + 3]))))
error (1, errno, "%s", argv[optind]);
error (4, 0, "fifo files not supported");
#else
if (argc - optind != 2)
- usage ();
+ usage (1);
if (mkfifo (argv[optind], newmode))
error (1, errno, "%s", argv[optind]);
#endif
break;
default:
- usage ();
+ usage (1);
}
exit (0);
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [options] path {bcu} major minor\n\
- %s [options] path p\n\
-Options:\n\
- [-m mode] [--mode=mode] [--help] [--version]\n",
- program_name, program_name);
- exit (1);
+Usage: %s [OPTION]... PATH TYPE [MAJOR MINOR]\n\
+\n",
+ program_name);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -m, --mode MODE set permission mode (as in chmod), not 0666 - umask\n\
+ --help provide this help\n\
+ --version show program version\n\
+\n\
+MAJOR MINOR are forbidden for TYPE p, mandatory otherwise. TYPE may be:\n\
+\n\
+ b create a block (buffered) special file\n\
+ c, u create a character (unbuffered) special file \n\
+ p create a FIFO\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
-i, --interactive Require confirmation from the user before
performing any move that would destroy an
- existing file.
+ existing file.
-u, --update Do not move a nondirectory that has an
existing destination with the same or newer
- modification time.
+ modification time.
-v, --verbose List the name of each file as it is moved, and
- the name it is moved to.
+ the name it is moved to.
-b, --backup
-S, --suffix
version = optarg;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (argc < optind + 2)
- usage ();
+ usage (1);
if (make_backups)
backup_type = get_version (version);
if (copy_reg (source, dest))
goto un_backup;
-
+
if (unlink (source))
{
error (0, errno, "cannot remove `%s'", source);
int ofd;
char buf[1024 * 8];
int len; /* Number of bytes read into `buf'. */
-
+
if (!S_ISREG (source_stats.st_mode))
{
error (0, 0, "cannot move `%s' across filesystems: Not a regular file",
source);
return 1;
}
-
+
if (unlink (dest) && errno != ENOENT)
{
error (0, errno, "cannot remove `%s'", dest);
{
int wrote = 0;
char *bp = buf;
-
+
do
{
wrote = write (ofd, bp, len);
error (0, errno, "%s", dest);
return 1;
}
-
+
/* chown turns off set[ug]id bits for non-root,
so do the chmod last. */
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [options] source dest\n\
- %s [options] source... directory\n\
-Options:\n\
- [-bfiuv] [-S backup-suffix] [-V {numbered,existing,simple}]\n\
- [--backup] [--force] [--interactive] [--update] [--verbose]\n\
- [--suffix=backup-suffix] [--version-control={numbered,existing,simple}]\n\
- [--help] [--version]\n",
+Usage: %s [OPTION]... SOURCE DEST\n\
+ or: %s [OPTION]... SOURCE... DIRECTORY\n\
+\n",
program_name, program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -b, --backup make backup before removal\n\
+ -f, --force remove existing destinations, never prompt\n\
+ -i, --interactive prompt before overwrite\n\
+ -u, --update move only older or brand new files\n\
+ -v, --verbose explain what is being done\n\
+ -S, --suffix SUFFIX override the usual backup suffix\n\
+ -V, --version-control WORD override the usual version control\n\
+ --help provide this help\n\
+ --version show program version\n\
+\n\
+The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The\n\
+version control may be set with VERSION_CONTROL, values are:\n\
+\n\
+ t, numbered make numbered backups\n\
+ nil, existing numbered if numbered backups exist, simple otherwise\n\
+ never, simple always make simple backups \n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
verbose = 1;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (optind == argc)
{
if (ignore_missing_files)
exit (0);
else
- usage ();
+ usage (1);
}
stdin_tty = isatty (0);
}
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-dfirvR] [--directory] [--force] [--interactive] [--recursive]\n\
- [--verbose] [--help] [--version] path...\n",
+Usage: %s [OPTION]... PATH...\n\
+\n",
program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -d, --directory unlink directory, even if non-empty (super-user only)\n\
+ -f, --force ignore nonexistent files, never prompt\n\
+ -i, --interactive prompt before any removal\n\
+ -v, --verbose explain what is being done\n\
+ -r, -R, --recursive remove the contents of directories recursively\n\
+ --help provide this help\n\
+ --version show program version\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
empty_paths = 1;
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (optind == argc)
- usage ();
+ usage (1);
for (; optind < argc; ++optind)
{
}
static void
-usage ()
+usage (status)
+ int status;
{
- fprintf (stderr, "Usage: %s [-p] [--parents] [--help] [--version] dir...\n",
+ fprintf (stderr, "\
+Usage: %s [OPTION]... DIRECTORY...\n\
+\n",
program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -p, --parents remove explicit parent directories if being emptied\n\
+ --help provide this help\n\
+ --version show program version\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}
-r, --file=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.
if (i < 0)
{
invalid_arg ("time selector", optarg, i);
- usage ();
+ usage (1);
}
change_times |= time_masks[i];
break;
default:
- usage ();
+ usage (1);
}
}
}
if (show_help)
- usage ();
+ usage (0);
if (change_times == 0)
change_times = CH_ATIME | CH_MTIME;
|| (posix_date && flexible_date))
{
error (0, 0, "cannot specify times from more than one source");
- usage ();
+ usage (1);
}
if (use_ref)
if (optind == argc)
{
error (0, 0, "file arguments missing");
- usage ();
+ usage (1);
}
for (; optind < argc; ++optind)
{
error (0, errno, "%s", file);
return 1;
- }
+ }
}
if (amtime_now)
status = utime (file, &utb);
}
-
+
if (status)
{
error (0, errno, "%s", file);
#endif
static void
-usage ()
+usage (status)
+ int status;
{
fprintf (stderr, "\
-Usage: %s [-acfm] [-r reference-file] [-t MMDDhhmm[[CC]YY][.ss]]\n\
- [-d time] [--time={atime,access,use,mtime,modify}] [--date=time]\n\
- [--file=reference-file] [--no-create] [--help] [--version] file...\n",
+Usage: %s [OPTION]... FILE...\n\
+\n",
program_name);
- exit (1);
+
+ if (status == 0)
+ fprintf (stderr, "\
+ -a change the access time only\n\
+ -c do not create files that do not exist\n\
+ -d, --date STRING parse STRING and use it, instead of current time\n\
+ -f (ignored)\n\
+ -m change the modification time only\n\
+ -r, --file REFERENCE use this file's times, instead of current time\n\
+ -t STAMP use MMDDhhmm[[CC]YY][.ss], instead of current time\n\
+ --help provide this help\n\
+ --time WORD access -a, atime -a, mtime -m, modify -m, use -a\n\
+ --version show program version\n\
+\n\
+STAMP may be used without -t if none of -drt, nor --, are used.\n");
+
+ else
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+
+ exit (status);
}