From 95f7eb6267b6fa36b92e247eca2728cde8130f03 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 8 Oct 1993 00:51:10 +0000 Subject: merge with 3.8.3d --- src/chgrp.c | 29 ++++++++++--- src/chmod.c | 36 ++++++++++++---- src/chown.c | 37 ++++++++++++---- src/cp.c | 21 ++++----- src/dd.c | 61 +++++++++++++++++++------- src/df.c | 33 +++++++++++--- src/du.c | 35 +++++++++++---- src/install.c | 39 +++++++++++------ src/ln.c | 50 ++++++++++++++++------ src/ls.c | 135 ++++++++++++++++++++++++++++++++++++++-------------------- src/mkdir.c | 28 +++++++++--- src/mkfifo.c | 25 ++++++++--- src/mknod.c | 44 +++++++++++++------ src/mv.c | 61 +++++++++++++++++--------- src/rm.c | 30 ++++++++++--- src/rmdir.c | 26 ++++++++--- src/touch.c | 46 ++++++++++++++------ 17 files changed, 527 insertions(+), 209 deletions(-) (limited to 'src') diff --git a/src/chgrp.c b/src/chgrp.c index ca66a595c..b148476e3 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -134,7 +134,7 @@ main (argc, argv) verbose = 1; break; default: - usage (); + usage (1); } } @@ -145,10 +145,10 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (optind >= argc - 1) - usage (); + usage (1); parse_group (argv[optind++], &group); @@ -304,11 +304,26 @@ isnumber (str) } 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); } diff --git a/src/chmod.c b/src/chmod.c index 511e3e22a..9df0c33be 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -149,7 +149,7 @@ main (argc, argv) verbose = 1; break; default: - usage (); + usage (1); } } @@ -160,13 +160,13 @@ main (argc, argv) } 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); @@ -302,12 +302,30 @@ describe_change (file, mode, changed) } 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); } diff --git a/src/chown.c b/src/chown.c index c295f5816..15848837b 100644 --- a/src/chown.c +++ b/src/chown.c @@ -15,7 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* +/* | user | unchanged explicit -------------|-------------------------+-------------------------| @@ -146,7 +146,7 @@ main (argc, argv) verbose = 1; break; default: - usage (); + usage (1); } } @@ -157,10 +157,10 @@ main (argc, argv) } 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) @@ -292,11 +292,30 @@ describe_change (file, changed) } 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); } diff --git a/src/cp.c b/src/cp.c index c1ae72c84..5d88f99aa 100644 --- a/src/cp.c +++ b/src/cp.c @@ -268,7 +268,7 @@ main (argc, argv) break; default: - usage ((char *) 0); + usage ((char *) 0, 2); } } @@ -279,10 +279,10 @@ main (argc, argv) } 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); @@ -321,9 +321,9 @@ do_copy (argc, argv) 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]; @@ -405,7 +405,7 @@ do_copy (argc, argv) { 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, @@ -427,7 +427,7 @@ do_copy (argc, argv) 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]; @@ -459,7 +459,8 @@ do_copy (argc, argv) 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); } /* Copy the file SRC_PATH to the file DST_PATH. The files may be of @@ -882,7 +883,7 @@ make_path (const_dirpath, src_offset, mode, verbose_fmt_string, 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); @@ -998,7 +999,7 @@ re_protect (const_dst_path, src_offset, attr_list) 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) { diff --git a/src/dd.c b/src/dd.c index bde611cef..88c2c285f 100644 --- a/src/dd.c +++ b/src/dd.c @@ -359,7 +359,7 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); apply_translations (); @@ -394,7 +394,7 @@ main (argc, argv) } else output_file = "standard output"; - + #ifdef _POSIX_VERSION sigaction (SIGINT, NULL, &sigact); if (sigact.sa_handler != SIG_IGN) @@ -705,7 +705,7 @@ copy_simple (buf, nread) nfree = nread; bcopy (start, obuf + oc, nfree); - + nread -= nfree; /* Update the number of bytes left to copy. */ start += nfree; oc += nfree; @@ -822,7 +822,7 @@ scanargs (argc, argv) break; default: - usage (); + usage (1); } } @@ -835,7 +835,7 @@ scanargs (argc, argv) if (val == NULL) { error (0, 0, "unrecognized option `%s'", name); - usage (); + usage (1); } *val++ = '\0'; @@ -874,7 +874,7 @@ scanargs (argc, argv) else { error (0, 0, "unrecognized option `%s=%s'", name, val); - usage (); + usage (1); } } } @@ -960,7 +960,7 @@ parse_conversion (str) if (conversions[i].convname == NULL) { error (0, 0, "%s: invalid conversion", str); - usage (); + usage (1); } str = new; } while (new != NULL); @@ -1070,15 +1070,46 @@ interrupt_handler () } 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); } diff --git a/src/df.c b/src/df.c index 7b779258f..a4ef19df5 100644 --- a/src/df.c +++ b/src/df.c @@ -185,7 +185,7 @@ main (argc, argv) add_excluded_fs_type (optarg); break; default: - usage (); + usage (1); } } @@ -196,7 +196,7 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (optind != argc) { @@ -475,12 +475,31 @@ excluded_fstype (fstype) } 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); } diff --git a/src/du.c b/src/du.c index 5f538ec7f..89bc12760 100644 --- a/src/du.c +++ b/src/du.c @@ -191,19 +191,38 @@ static struct option const long_options[] = }; 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); } void @@ -266,7 +285,7 @@ main (argc, argv) break; default: - usage ((char *) 0); + usage ((char *) 0, 2); } } @@ -277,10 +296,10 @@ main (argc, argv) } 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); diff --git a/src/install.c b/src/install.c index 075620085..2c238689f 100644 --- a/src/install.c +++ b/src/install.c @@ -204,7 +204,7 @@ main (argc, argv) owner_name = optarg; break; default: - usage (); + usage (1); } } @@ -215,13 +215,13 @@ main (argc, argv) } 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) { @@ -255,7 +255,7 @@ main (argc, argv) else { if (!isdir (argv[argc - 1])) - usage (); + usage (1); for (; optind < argc - 1; ++optind) { errors |= install_file_in_dir (argv[optind], argv[argc - 1]); @@ -537,15 +537,30 @@ isnumber (str) } 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); } diff --git a/src/ln.c b/src/ln.c index 8e96eb848..05137f924 100644 --- a/src/ln.c +++ b/src/ln.c @@ -104,7 +104,7 @@ static int show_help; /* 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}, @@ -178,7 +178,7 @@ main (argc, argv) version = optarg; break; default: - usage (); + usage (1); break; } } @@ -190,10 +190,10 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (optind == argc) - usage (); + usage (1); if (make_backups) backup_type = get_version (version); @@ -324,7 +324,7 @@ do_link (source, dest) error (0, errno, "%s", dest); return 1; } - + if (verbose) printf ("%s -> %s\n", source, dest); @@ -350,16 +350,38 @@ do_link (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); } diff --git a/src/ls.c b/src/ls.c index 9db617448..6082408df 100644 --- a/src/ls.c +++ b/src/ls.c @@ -465,7 +465,7 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); format_needs_stat = sort_type == sort_time || sort_type == sort_size || format == long_format @@ -615,16 +615,16 @@ decode_switches (argc, argv) 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; @@ -647,106 +647,106 @@ decode_switches (argc, argv) 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) @@ -770,7 +770,7 @@ decode_switches (argc, argv) if (i < 0) { invalid_arg ("sort type", optarg, i); - usage (); + usage (1); } sort_type = sort_types[i]; break; @@ -780,7 +780,7 @@ decode_switches (argc, argv) if (i < 0) { invalid_arg ("time type", optarg, i); - usage (); + usage (1); } time_type = time_types[i]; break; @@ -790,13 +790,13 @@ decode_switches (argc, argv) if (i < 0) { invalid_arg ("format type", optarg, i); - usage (); + usage (1); } format = formats[i]; break; - + default: - usage (); + usage (1); } } @@ -1877,19 +1877,64 @@ attach (dest, dirname, name) } 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); } diff --git a/src/mkdir.c b/src/mkdir.c index 1167c1a2e..5ed40b84b 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -99,7 +99,7 @@ main (argc, argv) symbolic_mode = optarg; break; default: - usage (); + usage (1); } } @@ -110,10 +110,10 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (optind == argc) - usage (); + usage (1); newmode = 0777 & ~umask (0); parent_mode = newmode | 0300; /* u+wx */ @@ -142,11 +142,25 @@ main (argc, argv) } 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); } diff --git a/src/mkfifo.c b/src/mkfifo.c index c15f740e6..efdf883e1 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -88,7 +88,7 @@ main (argc, argv) symbolic_mode = optarg; break; default: - usage (); + usage (1); } } @@ -99,10 +99,10 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (optind == argc) - usage (); + usage (1); newmode = 0666 & ~umask (0); if (symbolic_mode) @@ -130,11 +130,24 @@ main (argc, argv) #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 diff --git a/src/mknod.c b/src/mknod.c index 702435186..f9a614a7a 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -89,7 +89,7 @@ main (argc, argv) symbolic_mode = optarg; break; default: - usage (); + usage (1); } } @@ -100,7 +100,7 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); newmode = 0666 & ~umask (0); if (symbolic_mode) @@ -114,7 +114,7 @@ main (argc, argv) } 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'. */ @@ -126,7 +126,7 @@ main (argc, argv) 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]); @@ -139,7 +139,7 @@ main (argc, argv) 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]); @@ -151,27 +151,43 @@ main (argc, argv) 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); } diff --git a/src/mv.c b/src/mv.c index a5d22eb8e..c785bf3d7 100644 --- a/src/mv.c +++ b/src/mv.c @@ -21,14 +21,14 @@ -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 @@ -170,7 +170,7 @@ main (argc, argv) version = optarg; break; default: - usage (); + usage (1); } } @@ -181,10 +181,10 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (argc < optind + 2) - usage (); + usage (1); if (make_backups) backup_type = get_version (version); @@ -335,7 +335,7 @@ do_move (source, dest) if (copy_reg (source, dest)) goto un_backup; - + if (unlink (source)) { error (0, errno, "cannot remove `%s'", source); @@ -364,14 +364,14 @@ copy_reg (source, dest) 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); @@ -396,7 +396,7 @@ copy_reg (source, dest) { int wrote = 0; char *bp = buf; - + do { wrote = write (ofd, bp, len); @@ -432,7 +432,7 @@ copy_reg (source, dest) error (0, errno, "%s", dest); return 1; } - + /* chown turns off set[ug]id bits for non-root, so do the chmod last. */ @@ -468,16 +468,37 @@ copy_reg (source, dest) } 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); } diff --git a/src/rm.c b/src/rm.c index b20950f78..2b17e64c1 100644 --- a/src/rm.c +++ b/src/rm.c @@ -145,7 +145,7 @@ main (argc, argv) verbose = 1; break; default: - usage (); + usage (1); } } @@ -156,14 +156,14 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (optind == argc) { if (ignore_missing_files) exit (0); else - usage (); + usage (1); } stdin_tty = isatty (0); @@ -526,11 +526,27 @@ is the same file as\n", program_name, pathname); } 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); } diff --git a/src/rmdir.c b/src/rmdir.c index ac4c88c50..07ad705c2 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -87,7 +87,7 @@ main (argc, argv) empty_paths = 1; break; default: - usage (); + usage (1); } } @@ -98,10 +98,10 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (optind == argc) - usage (); + usage (1); for (; optind < argc; ++optind) { @@ -144,9 +144,23 @@ remove_parents (path) } 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); } diff --git a/src/touch.c b/src/touch.c index dc1d06f95..35b3d8f16 100644 --- a/src/touch.c +++ b/src/touch.c @@ -24,7 +24,7 @@ -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. @@ -194,13 +194,13 @@ main (argc, argv) if (i < 0) { invalid_arg ("time selector", optarg, i); - usage (); + usage (1); } change_times |= time_masks[i]; break; default: - usage (); + usage (1); } } @@ -211,7 +211,7 @@ main (argc, argv) } if (show_help) - usage (); + usage (0); if (change_times == 0) change_times = CH_ATIME | CH_MTIME; @@ -220,7 +220,7 @@ main (argc, argv) || (posix_date && flexible_date)) { error (0, 0, "cannot specify times from more than one source"); - usage (); + usage (1); } if (use_ref) @@ -250,7 +250,7 @@ main (argc, argv) if (optind == argc) { error (0, 0, "file arguments missing"); - usage (); + usage (1); } for (; optind < argc; ++optind) @@ -304,7 +304,7 @@ touch (file) { error (0, errno, "%s", file); return 1; - } + } } if (amtime_now) @@ -337,7 +337,7 @@ touch (file) status = utime (file, &utb); } - + if (status) { error (0, errno, "%s", file); @@ -376,12 +376,32 @@ utime_now (file, filesize) #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); } -- cgit v1.2.3-70-g09d2