Jim Meyering <[EMAIL PROTECTED]> writes: > If you do that, you should also adjust `chown --help' output > and coreutils.texi to describe the new default behavior.
But the practice elsewhere is to not document the old-fashioned POSIX 1003.2-1992 behavior in help strings; for example, "sort --help" and "tail --help" don't. As I caused this problem originally (sorry!), I looked into the POSIX spec with tweezers and a fine-toothed comb, and I spotted an escape hatch. Here is a simpler (and what I hope is a better) proposal: have chown support the old syntax regardless of POSIX version of POSIXLY_CORRECT. This conforms, is because POSIX allows the "chown user.group file" behavior as an upward-compatible extension, so long as it comes into play only where a vanilla chown would report an error (which is what the code already does). Here is a proposed patch. 2004-02-23 Paul Eggert <[EMAIL PROTECTED]> * NEWS: Document the following. * doc/coreutils.texi (chown invocation): Likewise. * lib/userspec.c: Don't include "posixver.h". (parse_user_spec): Fall back on USER.GROUP parsing regardless of POSIX version, as POSIX 1003.1-2001 allows that behavior as a compatible extension. Simplify code by removing a boolean int that was always nonzero if a string was nonnull. Index: NEWS =================================================================== RCS file: /home/meyering/coreutils/cu/NEWS,v retrieving revision 1.178 diff -p -u -r1.178 NEWS --- NEWS 21 Feb 2004 09:26:56 -0000 1.178 +++ NEWS 23 Feb 2004 23:02:56 -0000 @@ -14,6 +14,12 @@ GNU coreutils NEWS The `|' and `&' operators now use short-circuit evaluation, e.g., `expr 1 \| 1 / 0' no longer reports a division by zero. +** New features + + `chown user.group file' now has its traditional meaning even when + conforming to POSIX 1003.1-2001, so long as no user has a name + containing `.' that happens to equal `user.group'. + * Major changes in release 5.2.0 (2004-02-19) [stable] Index: doc/coreutils.texi =================================================================== RCS file: /home/meyering/coreutils/cu/doc/coreutils.texi,v retrieving revision 1.161 diff -p -u -r1.161 coreutils.texi --- doc/coreutils.texi 22 Feb 2004 15:44:32 -0000 1.161 +++ doc/coreutils.texi 23 Feb 2004 23:05:15 -0000 @@ -7712,11 +7712,13 @@ is omitted, only the group of the files @end table Some older scripts may still use @samp{.} in place of the @samp{:} separator. [EMAIL PROTECTED] 1003.1-2001 (@pxref{Standards conformance}) does not allow that, -but you may be able to work around the compatibility problems by setting [EMAIL PROTECTED] in your environment. -New scripts should avoid the use of @samp{.} because @sc{gnu} @command{chown} -may fail if @var{owner} contains @samp{.} characters. [EMAIL PROTECTED] 1003.1-2001 (@pxref{Standards conformance}) does not +require support for that, but for backward compatibility @acronym{GNU} [EMAIL PROTECTED] supports @samp{.} so long as no ambiguity results. +New scripts should avoid the use of @samp{.} because it is not +portable, and because it has undesirable results if the entire [EMAIL PROTECTED]@samp{.}group} happens to identify a user whose name +contains @samp{.}. Warning: The @command{chown} command may clear the set-user-ID or set-group-ID bits on some systems. The @command{chown} command is Index: lib/userspec.c =================================================================== RCS file: /home/meyering/coreutils/cu/lib/userspec.c,v retrieving revision 1.39 diff -p -u -r1.39 userspec.c --- lib/userspec.c 3 Nov 2003 14:57:41 -0000 1.39 +++ lib/userspec.c 23 Feb 2004 21:34:10 -0000 @@ -42,7 +42,6 @@ #endif #include "userspec.h" -#include "posixver.h" #include "xalloc.h" #include "xstrtol.h" @@ -158,7 +157,6 @@ parse_user_spec (const char *spec_arg, u struct group *grp; char *g, *u, *separator; char *groupname; - int maybe_retry = 0; char *dot = NULL; error_msg = NULL; @@ -171,17 +169,14 @@ parse_user_spec (const char *spec_arg, u separator = strchr (spec, ':'); /* If there is no colon, then see if there's a `.'. */ - if (separator == NULL && posix2_version () < 200112) + if (separator == NULL) { dot = strchr (spec, '.'); /* If there's no colon but there is a `.', then first look up the whole spec, in case it's an OWNER name that includes a dot. If that fails, then we'll try again, but interpreting the `.' - as a separator. */ - /* FIXME: accepting `.' as the separator is contrary to POSIX. - someday we should drop support for this. */ - if (dot) - maybe_retry = 1; + as a separator. This is a compatible extension to POSIX, since + the POSIX-required behavior is always tried first. */ } retry: @@ -311,10 +306,10 @@ parse_user_spec (const char *spec_arg, u } } - if (error_msg && maybe_retry) + if (error_msg && dot) { - maybe_retry = 0; separator = dot; + dot = NULL; error_msg = NULL; goto retry; } _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-coreutils