Commit Graph

4495 Commits

Author SHA1 Message Date
Jim Meyering 851acad0ce (usage, main): Output "file system" rather than "filesystem".
(long_options, usage): Rename "--filesystem" to
"--file-system".  But keep the old name around, for compatibility reasons.
2004-06-30 22:31:43 +00:00
Jim Meyering 3365c5f5e3 (usage, main): Output "file system" rather than "filesystem". 2004-06-30 22:31:43 +00:00
Jim Meyering 697c4afab5 . 2004-06-30 18:42:27 +00:00
Jim Meyering ba039472a8 Add support for --no-target-directory option.
(NO_TARGET_DIRECTORY_OPTION): New constant.
(long_options, usage, main): Add support for
2004-06-30 18:40:40 +00:00
Jim Meyering 0d27d8a0f8 Add support for --no-target-directory option.
(NO_TARGET_DIRECTORY_OPTION): New constant.
(long_options, usage, main): Add support for
(enum): Sort values.
2004-06-30 18:39:42 +00:00
Jim Meyering ab7ebdc363 Add support for --no-target-directory option.
(NO_TARGET_DIRECTORY_OPTION): New constant.
(long_options, usage, main): Add support for
2004-06-30 18:39:18 +00:00
Jim Meyering 7ed69a972c Add support for --no-target-directory option.
(NO_TARGET_DIRECTORY_OPTION): New constant.
(long_opts, usage, do_copy, main): Add support for
2004-06-30 18:38:24 +00:00
Jim Meyering 0ec60860b6 Add support for 'install --target-directory', an option
that has been documented for years but not implemented (!).

(TARGET_DIRECTORY_OPTION): New var.
(long_options, main, usage): Add --target-directory.
(target_directory_operand): New function, stolen from mv.c.
(main): Use it.  Check for -d and --target-directory.
Alter wording of diagnostics to match other programs.
2004-06-29 14:40:47 +00:00
Jim Meyering 6860c032da Use more-consistent rules among cp, ln, and mv when dealing with
last operands that are (or look like) directories.

	* src/cp.c (target_directory_operand): New, nearly-common function,
	It reports an error if the destination appears to be a directory
	(e.g., because it has a trailing slash) but is not.
	* src/ln.c, src/mv.c: Likewise.
	* src/cp.c (do_copy): Use it.
	* src/ln.c (main): Likewise.
	* src/mv.c (main): Likewise.

	* src/cp.c (do_copy): Don't output a usage message because of file
	problems (e.g., an operand is not a directory).  Use it only for
	syntax.  Standardize on "target %s is not a directory" for the
	diagnostic.
	* src/ln.c (main): Likewise.
	* src/mv.c (main): Likewise.

	* src/cp.c (do_copy): Remove test for trailing slash, since
	target_directory_operand now does this.
	* src/ln.c (main): Likewise.
	* src/mv.c (movefile): Likewise.

	* src/ln.c (isdir): Remove decl; no longer needed.
	* src/mv.c (isdir, lstat): Likewise.

	* src/ln.c (main): Use int to count to argc, not unsigned int.
	This handles negative operand counts.
	* src/mv.c (main): Likewise.

	* src/mv.c (do_move): Don't call hash_init; expect the caller to
	do it, for consistency with cp.c and ln.c.  All callers changed.
	(movefile): dest_is_dir parameter is now bool, not int.
	(main): Standardize on "missing destination file operand after %s"
	for the diagnostic, for consistency with cp.c.
2004-06-28 18:39:28 +00:00
Jim Meyering 59c3b53926 Use more-consistent rules among cp, ln, and mv when dealing with
last operands that are (or look like) directories.

	* src/cp.c (target_directory_operand): New, nearly-common function,
	It reports an error if the destination appears to be a directory
	(e.g., because it has a trailing slash) but is not.
	* src/ln.c, src/mv.c: Likewise.
	* src/cp.c (do_copy): Use it.
	* src/ln.c (main): Likewise.
	* src/mv.c (main): Likewise.

	* src/cp.c (do_copy): Don't output a usage message because of file
	problems (e.g., an operand is not a directory).  Use it only for
	syntax.  Standardize on "target %s is not a directory" for the
	diagnostic.
	* src/ln.c (main): Likewise.
	* src/mv.c (main): Likewise.

	* src/cp.c (do_copy): Remove test for trailing slash, since
	target_directory_operand now does this.
	* src/ln.c (main): Likewise.
	* src/mv.c (movefile): Likewise.

	* src/cp.c (main): Reject multiple target directories.
	Check whether a specified target is a directory when parsing the
	options, using stat.  This gives more-accurate diagnostics.
	* src/ln.c (main): Likewise.

	* src/ln.c (isdir): Remove decl; no longer needed.
	* src/mv.c (isdir, lstat): Likewise.

	* src/ln.c (do_link): New arg dest_is_dir.  All uses changed.
	Don't check the destination ourself; rely on dest_is_dir.
	This way we can avoid lstatting the destination in the
	usual case, and in the worst case we lstat 1, not 3 times.
	Don't bother to unlink unless link failed; this saves a syscall.
	Remove unnecessary backup_succeeded flag;
	it was identical to "dest_backup != NULL".

	* src/ln.c (main): Use int to count to argc, not unsigned int.
	This handles negative operand counts.
	* src/mv.c (main): Likewise.
2004-06-28 18:38:05 +00:00
Jim Meyering 8340545c8b Use more-consistent rules among cp, ln, and mv when dealing with
last operands that are (or look like) directories.

	* src/cp.c (target_directory_operand): New, nearly-common function,
	It reports an error if the destination appears to be a directory
	(e.g., because it has a trailing slash) but is not.
	* src/cp.c (do_copy): Use it.

	* src/cp.c (do_copy): Don't assume argc is positive.
	Don't bother to lstat dest, since copy() will do that for us.
	Use "const" to avoid the need for cast.

	* src/cp.c (do_copy): Don't output a usage message because of file
	problems (e.g., an operand is not a directory).  Use it only for
	syntax.  Standardize on "target %s is not a directory" for the
	diagnostic.

	* src/cp.c (do_copy): Remove test for trailing slash, since
	target_directory_operand now does this.

	* src/cp.c (main): Reject multiple target directories.
	Check whether a specified target is a directory when parsing the
	options, using stat.  This gives more-accurate diagnostics.
2004-06-28 18:35:54 +00:00
Jim Meyering 86e30699e4 (usage): Fix copy+paste error in description of
--target-directory: s/move/copy/.  From Paul Jarc.
2004-06-28 18:31:46 +00:00
Jim Meyering 6fb6c5e33c . 2004-06-28 08:17:34 +00:00
Jim Meyering 54cdcb1a1a Fix a bug: formerly, if d/x was a directory and x a file, "ln x
d/" incorrectly created a link d/x/x.  It also saves some system
calls.

(main): Don't append basename to dest if this
results in an existing directory name.
2004-06-27 09:41:23 +00:00
Jim Meyering 4e6aaa2732 put \n in format string, not in actual diagnostic 2004-06-26 13:12:42 +00:00
Jim Meyering b5110a1746 (main): When given no arguments, print the standard
"missing operand\nTry printf --help..." message -- to be consistent.
2004-06-26 13:09:17 +00:00
Jim Meyering cf0071c5b0 (main): Add \n at the end of message output via fprintf. 2004-06-26 12:43:44 +00:00
Jim Meyering cb9c7daeea (do_link): Remove unnecessary call to lstat.
(main): Avoid subscript error when the destination is "".
2004-06-25 06:51:51 +00:00
Jim Meyering 678207c7d0 . 2004-06-23 15:09:27 +00:00
Jim Meyering 22191da8fb (idle_string, print_user): New arg boottime,
specifying the most recent boot time.  All uses changed.
(idle_string) Consider a line to be "old" if it hasn't been used
since the last boot time.  Watch out for overflow when computing
times, and for times in the future.
(idle_string): Record latest boot time.
2004-06-23 14:48:16 +00:00
Jim Meyering 6eb57b59ad The 2004-06-19 fix for who and pinky was incomplete, as ctime
has undefined behavior if the year precedes -999 or follows 9999.
Since we have to stop using ctime anyway, we might as well use
strftime and fix the FIXME, and support internationalized dates.

* src/who.c: Include "hard-locale.h".
(time_format, time_format_width): New vars.
(time_string, print_line): Use them.
(main): Set them.
(time_string): Use localtime + strftime instead of
ctime, to avoid problems with years before -999 or after 9999.
* src/pinky.c: Likewise.
2004-06-22 15:00:53 +00:00
Jim Meyering f581b96e7f The 2004-06-19 fix for who and pinky was incomplete, as ctime
has undefined behavior if the year precedes -999 or follows 9999.
Since we have to stop using ctime anyway, we might as well use
strftime and fix the FIXME, and support internationalized dates.

Include "hard-locale.h".
(time_format, time_format_width): New vars.
(time_string, print_line): Use them.
(main): Set them.
(time_string): Use localtime + strftime instead of
ctime, to avoid problems with years before -999 or after 9999.
2004-06-22 14:56:46 +00:00
Jim Meyering 1aee773227 (usage): Correct description of `-t FD'. The file
descriptor, FD, is no longer optional.  Reported by Ton Nijkes.
2004-06-22 14:55:30 +00:00
Jim Meyering e1de0b295e Fix bug: GNU 'ls' didn't count columns correctly if user or group
names contained multibyte characters where the column count
differed from the byte count.  This patch also corrects
some comments.

(format_user_or_group): New function, which counts columns correctly.
(format_user, format_group): Use it.
(format_user_or_group_width): New function, which counts columns correctly.
(format_user_width, format_group_width): Use it.
2004-06-22 12:50:01 +00:00
Jim Meyering 2ea2857ed4 . 2004-06-21 15:36:56 +00:00
Jim Meyering f53347b996 (main): Don't segfault when calculating the
expected number of operands for `mknod NAME'.
2004-06-21 15:35:12 +00:00
Jim Meyering 1ce7b61d0e (main): Standardize on the diagnostics given when someone gives
too few operands ("missing operand after `xxx'") or
too many operands ("extra operand `xxx'").
Include "quote.h" and/or "error.h" if it wasn't already being included.
2004-06-21 15:03:35 +00:00
Jim Meyering 110be46897 Standardize on the diagnostics given when someone gives
too few operands ("missing operand after `xxx'") or
too many operands ("extra operand `xxx'").
Include "quote.h" and/or "error.h" if it wasn't already being included.
(do_copy): Likewise.
2004-06-21 15:02:28 +00:00
Jim Meyering bddcb0eab2 Standardize on the diagnostics given when someone gives
too few operands ("missing operand after `xxx'") or
too many operands ("extra operand `xxx'").
Include "quote.h" and/or "error.h" if it wasn't already being included.
(add_file_name, main): Likewise.
2004-06-21 15:02:14 +00:00
Jim Meyering f04e77d364 Standardize on the diagnostics given when someone gives
too few operands ("missing operand after `xxx'") or
too many operands ("extra operand `xxx'").
Include "quote.h" and/or "error.h" if it wasn't already being included.
(beyond, main): Likewise.
2004-06-21 15:01:54 +00:00
Jim Meyering a20574f431 (input_seek_errno): Declare file-scoped variable as static. 2004-06-20 14:24:12 +00:00
Jim Meyering fb2a3c8a63 Remove declaration of yesno.
Instead, include yesno.h.
2004-06-20 13:47:24 +00:00
Jim Meyering 1c7b9917a2 Include yesno.h.
(top_dir): Remove now-unnecessary cast of obstack_base.
(pop_dir): Likewise.
(full_filename_): Likewise.
2004-06-20 13:44:12 +00:00
Jim Meyering 0171abddcd Don't dump core if ctime returns NULL; this is possible on
hosts with 64-bit time_t and 32-bit int.

Include "inttostr.h".
(time_string): New function, copied from who.c.
(print_entry): Use it.
2004-06-20 06:56:52 +00:00
Jim Meyering f2d779e87c Don't dump core if ctime returns NULL; this is possible on
hosts with 64-bit time_t and 32-bit int.

Include "inttostr.h".
(time_string): If ctime fails, print the raw time as an integer
instead of dumping core.
2004-06-20 06:53:05 +00:00
Jim Meyering 837232227c (print_line): Don't truncate user names at 8 bytes.
Problem reported by Guido Leenders in:
http://lists.gnu.org/archive/html/bug-coreutils/2004-06/msg00056.html
2004-06-20 06:49:42 +00:00
Jim Meyering 927e4d998e (case_GETOPT_VERSION_CHAR): Switch back to using GNU_PACKAGE (from
PACKAGE) once again.  This restores `GNU' to the parenthesized package
name in --version output.  Before, the first argument from AC_INIT,
`GNU coreutils', would be propagated to the PACKAGE variable.  Now,
`GNU ' is trimmed.  Reported by Richard Stallman.
2004-06-19 09:23:52 +00:00
Jim Meyering a8253c6acf (to_uchar): Rename function from `uchar'. The latter
would clash with a typedef in Tru64's <sys/types.h>.  From Albert Chin.
2004-06-17 21:32:45 +00:00
Jim Meyering fb7e0d8840 . 2004-06-17 14:48:08 +00:00
Jim Meyering 72f51d66bf (main): Recognize --help and --version even if POSIXLY_CORRECT is set. 2004-06-17 14:34:07 +00:00
Jim Meyering 7870fa1081 (main): Handle "--". 2004-06-17 13:09:21 +00:00
Jim Meyering ba01709da8 (main): Recognize --help, --version even if
POSIXLY_CORRECT.  POSIX does not specify any options, but it
does not prohibit options either, so "unlink" is like "expr" here.
2004-06-15 18:04:13 +00:00
Jim Meyering b10701b78e (parse_obsolescent_option): Support multiple file operands
even if POSIXLY_CORRECT, since POSIX does not require a diagnostic.
2004-06-15 18:00:58 +00:00
Jim Meyering 5afcf8697f (print_esc): Support \x, \u, \U even if POSIXLY_CORRECT,
since POSIX says the behavior is unspecified here.
(main): Recognize --help, --version even if
POSIXLY_CORRECT.  POSIX does not specify any options, but it
does not prohibit options either, so "printf" is like "expr" here.
2004-06-15 18:00:35 +00:00
Jim Meyering db2fa4fdcd Include "hard-locale.h".
(main): When in a non-POSIX locale, ignore POSIXLY_CORRECT, since
POSIX specifies the behavior only in the POSIX locale.
2004-06-15 18:00:20 +00:00
Jim Meyering 1391da81e0 (decode_switches): Pay attention to TABSIZE even if POSIXLY_CORRECT
is set.  POSIX reserves upper-case environment variables to the
implementation, so it's OK for ls to depend on TABSIZE.
2004-06-15 18:00:03 +00:00
Jim Meyering b276da216d Remove declaration of euidaccess.
Instead, include "euidaccess.h".
2004-06-14 14:40:12 +00:00
Jim Meyering 5bca9fb5f3 (PIDSTR_DECL_AND_INIT): Don't assume pid_t fits in int.
(UT_ID) [!HAVE_STRUCT_XTMP_UT_ID]: Remove bogus comment,
as (sizeof "??") reliably returns 3.
(print_line): Guard against idle and pid being too long
(which is possible when printing headers).
(print_user): Allocate enough bytes for idlestr.  Use IDLESTR_LEN.
Avoid unnecessary cast of sizeof to int.
(make_id_equals_comment): Do not assume that UT_ID returns
a string; it might return a non-null-terminated array.
Use strncat instead.  It's not very often where strncat is
exactly what you want, but this is one of those rare cases.
2004-06-13 22:03:07 +00:00
Jim Meyering 69cf3d4811 (list_entries_who): Don't output a trailing space. 2004-06-12 08:05:59 +00:00
Jim Meyering d25e88d25a (usage): Improve wording in description of the --time=WORD option. 2004-06-09 14:47:29 +00:00