bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-t and -T options for cp/mv/ln/install


From: Paul Eggert
Subject: -t and -T options for cp/mv/ln/install
Date: Thu, 01 Jul 2004 16:34:25 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Here's a patch to add support for -t as a short name for
--target-directory, and -T as a short name for --no-target-directory.

Index: ChangeLog
===================================================================
RCS file: /home/meyering/coreutils/cu/ChangeLog,v
retrieving revision 1.975
diff -p -u -r1.975 ChangeLog
--- ChangeLog   30 Jun 2004 22:35:51 -0000      1.975
+++ ChangeLog   1 Jul 2004 21:34:25 -0000
@@ -1,3 +1,18 @@
+2004-07-01  Paul Eggert  <address@hidden>
+
+       * NEWS: Add short names -t and -T for --target-directory
+       and --no-target-directory options, respectively.
+
+       * src/cp.c (NO_TARGET_DIRECTORY_OPTION, TARGET_DIRECTORY_OPTION):
+       Remove.  All uses changed to 'T' and 't', respectively.
+       * src/install.c, src/ln.c, src/mv.c: Likewise.
+
+       * src/cp.c (long_opts, usage, do_copy, main): Add -t and -T as
+       aliases for --target-directory and --no-target-directory,
+       respectively.
+       * src/install.c (long_options, main, usage): Likewise.
+       * src/ln.c, src/mv.c: Likewise.
+
 2004-07-01  Jim Meyering  <address@hidden>
 
        * Version 5.3.0.
Index: NEWS
===================================================================
RCS file: /home/meyering/coreutils/cu/NEWS,v
retrieving revision 1.222
diff -p -u -r1.222 NEWS
--- NEWS        30 Jun 2004 22:41:35 -0000      1.222
+++ NEWS        1 Jul 2004 05:30:35 -0000
@@ -75,7 +75,8 @@ GNU coreutils NEWS                      
   pwd now works even when run from a working directory whose name
   is longer than PATH_MAX.
 
-  cp, install, ln, and mv have a new --no-target-directory option.
+  cp, install, ln, and mv have a new --no-target-directory (-T) option,
+  and -t is now a short name for their --target-directory option.
 
   cp -pu and mv -u (when copying) now don't bother to update the
   destination if the resulting time stamp would be no newer than the
Index: doc/ChangeLog
===================================================================
RCS file: /home/meyering/coreutils/cu/doc/ChangeLog,v
retrieving revision 1.173
diff -p -u -r1.173 ChangeLog
--- doc/ChangeLog       30 Jun 2004 22:09:36 -0000      1.173
+++ doc/ChangeLog       1 Jul 2004 21:28:09 -0000
@@ -1,3 +1,11 @@
+2004-07-01  Paul Eggert  <address@hidden>
+
+       * coreutils.texi (Common options, Target directory, cp invocation,
+       install invocation, mv invocation, ln invocation): Add -t as a
+       short option for --target-directory, and -T as a short option for
+       --no-target-directory.  Clean up relevant synopses a bit, so that
+       the language is similar for all.
+
 2004-06-30  Paul Eggert  <address@hidden>
 
        * coreutils.texi, perm.texi: Standardize on "file system" rather
Index: doc/coreutils.texi
===================================================================
RCS file: /home/meyering/coreutils/cu/doc/coreutils.texi,v
retrieving revision 1.192
diff -p -u -r1.192 coreutils.texi
--- doc/coreutils.texi  30 Jun 2004 22:09:00 -0000      1.192
+++ doc/coreutils.texi  1 Jul 2004 21:20:39 -0000
@@ -522,7 +522,9 @@ Append @var{suffix} to each backup file 
 @end macro
 
 @macro optTargetDirectory
address@hidden -t @var{directory}
 @itemx @address@hidden@var{directory}}
address@hidden -t
 @opindex --target-directory
 @cindex target directory
 @cindex destination directory
@@ -531,7 +533,9 @@ Specify the destination @var{directory}.
 @end macro
 
 @macro optNoTargetDirectory
address@hidden --no-target-directory
address@hidden -T
address@hidden --no-target-directory
address@hidden -T
 @opindex --no-target-directory
 @cindex target directory
 @cindex destination directory
@@ -634,7 +638,7 @@ context that requires a file name.
 * Exit status::                 Indicating program success or failure.
 * Backup options::              -b -S -V, in some programs.
 * Block size::                  BLOCK_SIZE and --block-size, in some programs.
-* Target directory::            --target-directory, in some programs.
+* Target directory::            Specifying a target directory, in some 
programs.
 * Trailing slashes::            --strip-trailing-slashes, in some programs.
 * Traversing symlinks::         -H, -L, or -P, in some programs.
 * Treating / specially::        --preserve-root and --no-preserve-root.
@@ -934,7 +938,8 @@ allow more fine-grained control:
 
 @table @samp
 
address@hidden --no-target-directory
address@hidden -T
address@hidden --no-target-directory
 @opindex --no-target-directory
 @cindex target directory
 @cindex destination directory
@@ -945,13 +950,14 @@ programs that operate in a shared area. 
 @file{/tmp/source} was renamed to @file{/tmp/dest}: it could have been
 renamed to @file{/tmp/dest/source} instead, if some other process
 created @file{/tmp/dest} as a directory.  However, if @file{mv
---no-target-directory /tmp/source /tmp/dest} succeeds, there is no
+-T /tmp/source /tmp/dest} succeeds, there is no
 question that @file{/tmp/source} was renamed to @file{/tmp/dest}.
 
 In the opposite situation, where you want the last operand to be
 treated as a directory and want a diagnostic otherwise, you can use
-the @option{--target-directory} option instead.
+the @option{--target-directory} (@option{-t}) option.
 
address@hidden -t @var{directory}
 @itemx @address@hidden@var{directory}}
 @opindex --target-directory
 @cindex target directory
@@ -975,21 +981,21 @@ invocation of the subject command.  (It 
 shell command, but that requires more human labor and brain power than
 it should.)
 
-The @address@hidden option allows the @command{cp},
+The @address@hidden (@option{-t}) option allows the @command{cp},
 @command{install}, @command{ln}, and @command{mv} programs to be used
 conveniently with @command{xargs}.  For example, you can move the files
 from the current directory to a sibling directory, @code{d} like this:
 (However, this doesn't move files whose names begin with @samp{.}.)
 
 @smallexample
-ls |xargs mv --target-directory=../d
+ls | xargs mv -t ../d
 @end smallexample
 
 If you use the @sc{gnu} @command{find} program, you can move @emph{all}
 files with this command:
 @example
 find . -mindepth 1 -maxdepth 1 \
-  | xargs mv --target-directory=../d
+  | xargs mv -t ../d
 @end example
 
 But that will fail if there are no files in the current directory
@@ -999,13 +1005,14 @@ The following example removes those limi
 @example
 find . -mindepth 1 -maxdepth 1 -print0 \
   | xargs --null --no-run-if-empty \
-      mv --target-directory=../d
+      mv -t ../d
 @end example
 
 @end table
 
 @noindent
-The @option{--target-directory} and @option{--no-target-directory}
+The @option{--target-directory} (@option{-t}) and
address@hidden (@option{-T})
 options cannot be combined.
 
 @node Trailing slashes
@@ -6159,18 +6166,26 @@ copying, moving (renaming), and deleting
 @command{cp} copies files (or, optionally, directories).  The copy is
 completely independent of the original.  You can either copy one file to
 another, or copy arbitrarily many files to a destination directory.
-Synopsis:
+Synopses:
 
 @example
-cp address@hidden@dots{} @var{source} @var{dest}
+cp address@hidden@dots{} [-T] @var{source} @var{dest}
 cp address@hidden@dots{} @address@hidden @var{directory}
+cp address@hidden@dots{} -t @var{directory} @address@hidden
 @end example
 
-If the last argument names an existing directory, @command{cp} copies each
address@hidden file into that directory (retaining the same name).
-Otherwise, if only two files are given, it copies the first onto the
-second.  It is an error if the last argument is not a directory and more
-than two non-option arguments are given.
address@hidden @bullet
address@hidden
+If two file names are given, @command{cp} copies the first file to the
+second.
+
address@hidden
+If the @option{--target-directory} (@option{-t}) option is given, or
+failing that if the last file is a directory and the
address@hidden (@option{-T}) option is not given,
address@hidden copies each @var{source} file to the specified directory,
+using the @var{source}s' names.
address@hidden itemize
 
 Generally, files are written just as they are read.  For exceptions,
 see the @option{--sparse} option below.
@@ -6297,8 +6312,6 @@ Make hard links instead of copies of non
 @opindex --dereference
 Always follow symbolic links.
 
address@hidden
-
 @item -P
 @itemx --no-dereference
 @opindex -P
@@ -6457,6 +6470,8 @@ results in an error message on systems t
 
 @optTargetDirectory
 
address@hidden
+
 @item -u
 @itemx --update
 @opindex -u
@@ -6758,16 +6773,29 @@ affected file descriptors, even after @c
 possible, their owner and group.  Synopses:
 
 @example
-install address@hidden@dots{} @var{source} @var{dest}
+install address@hidden@dots{} [-T] @var{source} @var{dest}
 install address@hidden@dots{} @address@hidden @var{directory}
-install address@hidden@dots{} address@hidden @address@hidden
-install -d address@hidden@dots{} @address@hidden
+install address@hidden@dots{} -t @var{directory} @address@hidden
+install address@hidden@dots{} -d @address@hidden
 @end example
 
-In the first of these, the @var{source} file is copied to the @var{dest}
-target file.  In the second and third, each @var{source} file is copied
-to the destination @var{directory}.  In the last, each @var{directory}
-(and any missing parent directories) is created.
address@hidden @bullet
address@hidden
+If two file names are given, @command{install} copies the first file to the
+second.
+
address@hidden
+If the @option{--target-directory} (@option{-t}) option is given, or
+failing that if the last file is a directory and the
address@hidden (@option{-T}) option is not given,
address@hidden copies each @var{source} file to the specified
+directory, using the @var{source}s' names.
+
address@hidden
+If the @option{--directory} (@option{-d}) option is given,
address@hidden creates each @var{directory} and any missing parent
+directories.
address@hidden itemize
 
 @cindex Makefiles, installing programs in
 @command{install} is similar to @command{cp}, but allows you to control the
@@ -6818,8 +6846,6 @@ which can be either an octal number, or 
 permissions}).  The default mode is @samp{u=rwx,go=rx}---read, write,
 and execute for the owner, and read and execute for group and other.
 
address@hidden
-
 @item -o @var{owner}
 @itemx address@hidden
 @opindex -o
@@ -6857,6 +6883,8 @@ Strip the symbol tables from installed b
 
 @optTargetDirectory
 
address@hidden
+
 @item -v
 @itemx --verbose
 @opindex -v
@@ -6875,18 +6903,26 @@ Print the name of each file before copyi
 
 @pindex mv
 
address@hidden moves or renames files (or directories).  Synopsis:
address@hidden moves or renames files (or directories).  Synopses:
 
 @example
-mv address@hidden@dots{} @var{source} @var{dest}
+mv address@hidden@dots{} [-T] @var{source} @var{dest}
 mv address@hidden@dots{} @address@hidden @var{directory}
+mv address@hidden@dots{} -t @var{directory} @address@hidden
 @end example
 
-If the last argument names an existing directory, @command{mv} moves each
-other given file into a file with the same name in that directory.
-Otherwise, if only two files are given, it renames the first as
-the second.  It is an error if the last argument is not a directory
-and more than two files are given.
address@hidden @bullet
address@hidden
+If two file names are given, @command{mv} moves the first file to the
+second.
+
address@hidden
+If the @option{--target-directory} (@option{-t}) option is given, or
+failing that if the last file is a directory and the
address@hidden (@option{-T}) option is not given,
address@hidden moves each @var{source} file to the specified
+directory, using the @var{source}s' names.
address@hidden itemize
 
 @command{mv} can move any type of file from one file system to another.
 Prior to version @code{4.0} of the fileutils,
@@ -6936,8 +6972,6 @@ Prompt whether to overwrite each existin
 of its permissions.  If the response does not begin with @samp{y} or
 @samp{Y}, the file is skipped.
 
address@hidden
-
 @itemx @address@hidden@var{how}]}
 @opindex --reply
 @cindex interactivity
@@ -6972,6 +7006,8 @@ Print the name of each file before movin
 
 @optTargetDirectory
 
address@hidden
+
 @optVersionControl
 
 @end table
@@ -7387,30 +7423,35 @@ with the @option{-s} option, it makes sy
 Synopses:
 
 @example
-ln address@hidden@dots{} @var{target} address@hidden
+ln address@hidden@dots{} [-T] @var{target} @var{linkname}
+ln address@hidden@dots{} @var{target}
 ln address@hidden@dots{} @address@hidden @var{directory}
+ln address@hidden@dots{} -t @var{directory} @address@hidden
 @end example
 
 @itemize @bullet
address@hidden
+If two file names are given, @command{ln} creates a link to the first
+file from the second.
 
address@hidden If the last argument names an existing directory, @command{ln} 
creates a
-link to each @var{target} file in that directory, using the
address@hidden' names.  (But see the description of the
address@hidden and @option{--no-target-directory} options below.)
-
address@hidden If two filenames are given, @command{ln} creates a link from the
-second to the first.
-
address@hidden If one @var{target} is given, @command{ln} creates a link to that
-file in the current directory.
-
address@hidden It is an error if the last argument is not a directory and more
-than two files are given.  Without @option{-f} or @option{-i} (see below),
address@hidden will not remove an existing file.  Use the @option{--backup}
-option to make @command{ln} rename existing files.
address@hidden
+If one @var{target} is given, @command{ln} creates a link to that file
+in the current directory.
 
address@hidden
+If the @option{--target-directory} (@option{-t}) option is given, or
+failing that if the last file is a directory and the
address@hidden (@option{-T}) option is not given,
address@hidden creates a link to each @var{target} file in the specified
+directory, using the @var{target}s' names.
 @end itemize
 
+Normally @command{ln} does not remove existing files.  Use the
address@hidden (@option{-f}) option to remove them unconditionally,
+the @option{--interactive} (@option{-i}) option to remove them
+conditionally, and the @option{--backup} (@option{-b}) option to
+rename them.
+
 @cindex hard link, defined
 @cindex inode, and hard links
 A @dfn{hard link} is another name for an existing file; the link and the
@@ -7481,10 +7522,8 @@ must delete or backup that symlink befor
 The default is to treat a destination that is a symlink to a directory
 just like a directory.
 
-This option is weaker than the @option{--no-target-directory} option,
-and has no effect if @option{--no-target-directory} is also given.
-
address@hidden
+This option is weaker than the @option{--no-target-directory}
+(@option{-T}) option, so it has no effect if both options are given.
 
 @item -s
 @itemx --symbolic
@@ -7496,6 +7535,8 @@ an error message on systems that do not 
 @optBackupSuffix
 
 @optTargetDirectory
+
address@hidden
 
 @item -v
 @itemx --verbose
Index: src/cp.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/cp.c,v
retrieving revision 1.197
diff -p -u -r1.197 cp.c
--- src/cp.c    30 Jun 2004 18:38:24 -0000      1.197
+++ src/cp.c    1 Jul 2004 05:44:56 -0000
@@ -70,13 +70,11 @@ enum
 {
   COPY_CONTENTS_OPTION = CHAR_MAX + 1,
   NO_PRESERVE_ATTRIBUTES_OPTION,
-  NO_TARGET_DIRECTORY_OPTION,
   PARENTS_OPTION,
   PRESERVE_ATTRIBUTES_OPTION,
   REPLY_OPTION,
   SPARSE_OPTION,
   STRIP_TRAILING_SLASHES_OPTION,
-  TARGET_DIRECTORY_OPTION,
   UNLINK_DEST_BEFORE_OPENING
 };
 
@@ -129,7 +127,7 @@ static struct option const long_opts[] =
   {"link", no_argument, NULL, 'l'},
   {"no-dereference", no_argument, NULL, 'P'},
   {"no-preserve", required_argument, NULL, NO_PRESERVE_ATTRIBUTES_OPTION},
-  {"no-target-directory", no_argument, NULL, NO_TARGET_DIRECTORY_OPTION},
+  {"no-target-directory", no_argument, NULL, 'T'},
   {"one-file-system", no_argument, NULL, 'x'},
   {"parents", no_argument, NULL, PARENTS_OPTION},
   {"path", no_argument, NULL, PARENTS_OPTION},   /* Deprecated.  */
@@ -141,7 +139,7 @@ static struct option const long_opts[] =
   {"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
   {"suffix", required_argument, NULL, 'S'},
   {"symbolic-link", no_argument, NULL, 's'},
-  {"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION},
+  {"target-directory", required_argument, NULL, 't'},
   {"update", no_argument, NULL, 'u'},
   {"verbose", no_argument, NULL, 'v'},
   {"version-control", required_argument, NULL, 'V'}, /* Deprecated. FIXME. */
@@ -159,9 +157,9 @@ usage (int status)
   else
     {
       printf (_("\
-Usage: %s [OPTION]... SOURCE DEST\n\
+Usage: %s [OPTION]... [-T] SOURCE DEST\n\
   or:  %s [OPTION]... SOURCE... DIRECTORY\n\
-  or:  %s [OPTION]... --target-directory=DIRECTORY SOURCE...\n\
+  or:  %s [OPTION]... -t DIRECTORY SOURCE...\n\
 "),
              program_name, program_name, program_name);
       fputs (_("\
@@ -213,8 +211,8 @@ Mandatory arguments to long options are 
       fputs (_("\
   -s, --symbolic-link          make symbolic links instead of copying\n\
   -S, --suffix=SUFFIX          override the usual backup suffix\n\
-      --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY\n\
-      --no-target-directory    treat DEST as a normal file\n\
+  -t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY\n\
+  -T, --no-target-directory    treat DEST as a normal file\n\
 "), stdout);
       fputs (_("\
   -u, --update                 copy only when the SOURCE file is newer\n\
@@ -518,8 +516,8 @@ do_copy (int n_files, char **file, const
     {
       if (target_directory)
        error (EXIT_FAILURE, 0,
-              _("Cannot combine --target-directory "
-                "and --no-target-directory"));
+              _("Cannot combine --target-directory (-t) "
+                "and --no-target-directory (-T)"));
       if (2 < n_files)
        {
          error (0, 0, _("extra operand %s"), quote (file[2]));
@@ -824,7 +822,8 @@ main (int argc, char **argv)
      we'll actually use backup_suffix_string.  */
   backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
 
-  while ((c = getopt_long (argc, argv, "abdfHilLprsuvxPRS:V:", long_opts, 
NULL))
+  while ((c = getopt_long (argc, argv, "abdfHilLprst:uvxPRS:TV:",
+                          long_opts, NULL))
         != -1)
     {
       switch (c)
@@ -897,10 +896,6 @@ main (int argc, char **argv)
          decode_preserve_arg (optarg, &x, 0);
          break;
 
-       case NO_TARGET_DIRECTORY_OPTION:
-         no_target_directory = true;
-         break;
-
        case PRESERVE_ATTRIBUTES_OPTION:
          if (optarg == NULL)
            {
@@ -951,7 +946,7 @@ main (int argc, char **argv)
 #endif
          break;
 
-       case TARGET_DIRECTORY_OPTION:
+       case 't':
          if (target_directory)
            error (EXIT_FAILURE, 0,
                   _("multiple target directories specified"));
@@ -965,6 +960,10 @@ main (int argc, char **argv)
                       quote (optarg));
            }
          target_directory = optarg;
+         break;
+
+       case 'T':
+         no_target_directory = true;
          break;
 
        case 'u':
Index: src/install.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/install.c,v
retrieving revision 1.162
diff -p -u -r1.162 install.c
--- src/install.c       30 Jun 2004 18:40:40 -0000      1.162
+++ src/install.c       1 Jul 2004 06:05:53 -0000
@@ -90,14 +90,6 @@ static void get_ids (void);
 static void strip (const char *path);
 void usage (int status);
 
-/* For long options that have no equivalent short option, use a
-   non-character as a pseudo short option, starting with CHAR_MAX + 1.  */
-enum
-{
-  NO_TARGET_DIRECTORY_OPTION = CHAR_MAX + 1,
-  TARGET_DIRECTORY_OPTION
-};
-
 /* The name this program was run with, for error messages. */
 char *program_name;
 
@@ -131,12 +123,12 @@ static struct option const long_options[
   {"directory", no_argument, NULL, 'd'},
   {"group", required_argument, NULL, 'g'},
   {"mode", required_argument, NULL, 'm'},
-  {"no-target-directory", no_argument, NULL, NO_TARGET_DIRECTORY_OPTION},
+  {"no-target-directory", no_argument, NULL, 'T'},
   {"owner", required_argument, NULL, 'o'},
   {"preserve-timestamps", no_argument, NULL, 'p'},
   {"strip", no_argument, NULL, 's'},
   {"suffix", required_argument, NULL, 'S'},
-  {"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION},
+  {"target-directory", required_argument, NULL, 't'},
   {"version-control", required_argument, NULL, 'V'}, /* Deprecated. FIXME. */
   {"verbose", no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
@@ -237,7 +229,7 @@ main (int argc, char **argv)
      we'll actually use backup_suffix_string.  */
   backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
 
-  while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pvV:S:", long_options,
+  while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pt:TvV:S:", long_options,
                              NULL)) != -1)
     {
       switch (optc)
@@ -281,9 +273,6 @@ main (int argc, char **argv)
        case 'm':
          specified_mode = optarg;
          break;
-       case NO_TARGET_DIRECTORY_OPTION:
-         no_target_directory = true;
-         break;
        case 'o':
          owner_name = optarg;
          break;
@@ -294,7 +283,7 @@ main (int argc, char **argv)
          make_backups = 1;
          backup_suffix_string = optarg;
          break;
-       case TARGET_DIRECTORY_OPTION:
+       case 't':
          if (target_directory)
            error (EXIT_FAILURE, 0,
                   _("multiple target directories specified"));
@@ -309,6 +298,9 @@ main (int argc, char **argv)
            }
          target_directory = optarg;
          break;
+       case 'T':
+         no_target_directory = true;
+         break;
        case_GETOPT_HELP_CHAR;
        case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
        default:
@@ -349,8 +341,8 @@ main (int argc, char **argv)
     {
       if (target_directory)
        error (EXIT_FAILURE, 0,
-              _("Cannot combine --target-directory "
-                "and --no-target-directory"));
+              _("Cannot combine --target-directory (-t) "
+                "and --no-target-directory (-T)"));
       if (2 < n_files)
        {
          error (0, 0, _("extra operand %s"), quote (file[2]));
@@ -662,16 +654,16 @@ usage (int status)
   else
     {
       printf (_("\
-Usage: %s [OPTION]... SOURCE DEST                            (1st format)\n\
-  or:  %s [OPTION]... SOURCE... DIRECTORY                    (2nd format)\n\
-  or:  %s [OPTION]... --target-directory=DIRECTORY SOURCE... (3rd format)\n\
-  or:  %s -d [OPTION]... DIRECTORY...                        (4th format)\n\
+Usage: %s [OPTION]... [-T] SOURCE DEST        (1st form)\n\
+  or:  %s [OPTION]... SOURCE... DIRECTORY     (2nd form)\n\
+  or:  %s [OPTION]... -t DIRECTORY SOURCE...  (3rd form)\n\
+  or:  %s [OPTION]... -d DIRECTORY...         (4th form)\n\
 "),
              program_name, program_name, program_name, program_name);
       fputs (_("\
-In the first three formats, copy SOURCE to DEST or multiple SOURCE(s) to\n\
+In the first three forms, copy SOURCE to DEST or multiple SOURCE(s) to\n\
 the existing DIRECTORY, while setting permission modes and owner/group.\n\
-In the fourth format, create all components of the given DIRECTORY(ies).\n\
+In the 4th form, create all components of the given DIRECTORY(ies).\n\
 \n\
 "), stdout);
       fputs (_("\
@@ -696,8 +688,8 @@ Mandatory arguments to long options are 
                         to corresponding destination files\n\
   -s, --strip         strip symbol tables, only for 1st and 2nd formats\n\
   -S, --suffix=SUFFIX override the usual backup suffix\n\
-      --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY\n\
-      --no-target-directory  treat DEST as a normal file\n\
+  -t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY\n\
+  -T, --no-target-directory  treat DEST as a normal file\n\
   -v, --verbose       print the name of each directory as it is created\n\
 "), stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
Index: src/ln.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/ln.c,v
retrieving revision 1.140
diff -p -u -r1.140 ln.c
--- src/ln.c    30 Jun 2004 18:39:18 -0000      1.140
+++ src/ln.c    1 Jul 2004 21:32:49 -0000
@@ -39,14 +39,6 @@
 # define ENABLE_HARD_LINK_TO_SYMLINK_WARNING 0
 #endif
 
-/* For long options that have no equivalent short option, use a
-   non-character as a pseudo short option, starting with CHAR_MAX + 1.  */
-enum
-{
-  NO_TARGET_DIRECTORY_OPTION = CHAR_MAX + 1,
-  TARGET_DIRECTORY_OPTION
-};
-
 int link ();                   /* Some systems don't declare this anywhere. */
 
 #ifdef S_ISLNK
@@ -127,11 +119,11 @@ static struct option const long_options[
   {"backup", optional_argument, NULL, 'b'},
   {"directory", no_argument, NULL, 'F'},
   {"no-dereference", no_argument, NULL, 'n'},
-  {"no-target-directory", no_argument, NULL, NO_TARGET_DIRECTORY_OPTION},
+  {"no-target-directory", no_argument, NULL, 'T'},
   {"force", no_argument, NULL, 'f'},
   {"interactive", no_argument, NULL, 'i'},
   {"suffix", required_argument, NULL, 'S'},
-  {"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION},
+  {"target-directory", required_argument, NULL, 't'},
   {"symbolic", no_argument, NULL, 's'},
   {"verbose", no_argument, NULL, 'v'},
   {"version-control", required_argument, NULL, 'V'}, /* Deprecated. FIXME. */
@@ -353,18 +345,18 @@ usage (int status)
   else
     {
       printf (_("\
-Usage: %s [OPTION]... TARGET [LINK_NAME]\n\
-  or:  %s [OPTION]... TARGET... DIRECTORY\n\
-  or:  %s [OPTION]... --target-directory=DIRECTORY TARGET...\n\
+Usage: %s [OPTION]... [-T] TARGET LINK_NAME   (1st form)\n\
+  or:  %s [OPTION]... TARGET                  (2nd form)\n\
+  or:  %s [OPTION]... TARGET... DIRECTORY     (3rd form)\n\
+  or:  %s [OPTION]... -t DIRECTORY TARGET...  (4th form)\n\
 "),
-             program_name, program_name, program_name);
+             program_name, program_name, program_name, program_name);
       fputs (_("\
-Create a link to the specified TARGET with optional LINK_NAME.\n\
-If LINK_NAME is omitted, a link with the same basename as the TARGET is\n\
-created in the current directory.  When using the second form with more\n\
-than one TARGET, the last argument must be a directory;  create links\n\
-in DIRECTORY to each TARGET.  Create hard links by default, symbolic\n\
-links with --symbolic.  When creating hard links, each TARGET must exist.\n\
+In the 1st form, create a link to TARGET with the name LINK_NAME.\n\
+In the 2nd form, create a link to TARGET in the current directory.\n\
+In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.\n\
+Create hard links by default, symbolic links with --symbolic.\n\
+When creating hard links, each TARGET must exist.\n\
 \n\
 "), stdout);
       fputs (_("\
@@ -386,9 +378,9 @@ Mandatory arguments to long options are 
 "), stdout);
       fputs (_("\
   -S, --suffix=SUFFIX         override the usual backup suffix\n\
-      --target-directory=DIRECTORY  specify the DIRECTORY in which to create\n\
+  -t, --target-directory=DIRECTORY  specify the DIRECTORY in which to create\n\
                                 the links\n\
-      --no-target-directory   treat LINK_NAME as a normal file\n\
+  -T, --no-target-directory   treat LINK_NAME as a normal file\n\
   -v, --verbose               print name of each file before linking\n\
 "), stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
@@ -440,7 +432,7 @@ main (int argc, char **argv)
     = hard_dir_link = 0;
   errors = 0;
 
-  while ((c = getopt_long (argc, argv, "bdfinsvFS:V:", long_options, NULL))
+  while ((c = getopt_long (argc, argv, "bdfinst:vFS:TV:", long_options, NULL))
         != -1)
     {
       switch (c)
@@ -475,9 +467,6 @@ main (int argc, char **argv)
        case 'n':
          dereference_dest_dir_symlinks = 0;
          break;
-       case NO_TARGET_DIRECTORY_OPTION:
-         no_target_directory = true;
-         break;
        case 's':
 #ifdef S_ISLNK
          symbolic_link = 1;
@@ -486,7 +475,7 @@ main (int argc, char **argv)
                 _("symbolic links are not supported on this system"));
 #endif
          break;
-       case TARGET_DIRECTORY_OPTION:
+       case 't':
          if (target_directory)
            error (EXIT_FAILURE, 0, _("multiple target directories specified"));
          else
@@ -499,6 +488,9 @@ main (int argc, char **argv)
                       quote (optarg));
            }
          target_directory = optarg;
+         break;
+       case 'T':
+         no_target_directory = true;
          break;
        case 'v':
          verbose = 1;
Index: src/mv.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mv.c,v
retrieving revision 1.157
diff -p -u -r1.157 mv.c
--- src/mv.c    30 Jun 2004 22:33:40 -0000      1.157
+++ src/mv.c    1 Jul 2004 05:47:12 -0000
@@ -49,10 +49,8 @@
    non-character as a pseudo short option, starting with CHAR_MAX + 1.  */
 enum
 {
-  NO_TARGET_DIRECTORY_OPTION = CHAR_MAX + 1,
-  REPLY_OPTION,
-  STRIP_TRAILING_SLASHES_OPTION,
-  TARGET_DIRECTORY_OPTION
+  REPLY_OPTION = CHAR_MAX + 1,
+  STRIP_TRAILING_SLASHES_OPTION
 };
 
 /* The name this program was run with. */
@@ -78,11 +76,11 @@ static struct option const long_options[
   {"backup", optional_argument, NULL, 'b'},
   {"force", no_argument, NULL, 'f'},
   {"interactive", no_argument, NULL, 'i'},
-  {"no-target-directory", no_argument, NULL, NO_TARGET_DIRECTORY_OPTION},
+  {"no-target-directory", no_argument, NULL, 'T'},
   {"reply", required_argument, NULL, REPLY_OPTION},
   {"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
   {"suffix", required_argument, NULL, 'S'},
-  {"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION},
+  {"target-directory", required_argument, NULL, 't'},
   {"update", no_argument, NULL, 'u'},
   {"verbose", no_argument, NULL, 'v'},
   {"version-control", required_argument, NULL, 'V'},
@@ -302,9 +300,9 @@ usage (int status)
   else
     {
       printf (_("\
-Usage: %s [OPTION]... SOURCE DEST\n\
+Usage: %s [OPTION]... [-T] SOURCE DEST\n\
   or:  %s [OPTION]... SOURCE... DIRECTORY\n\
-  or:  %s [OPTION]... --target-directory=DIRECTORY SOURCE...\n\
+  or:  %s [OPTION]... -t DIRECTORY SOURCE...\n\
 "),
              program_name, program_name, program_name);
       fputs (_("\
@@ -330,8 +328,8 @@ Mandatory arguments to long options are 
   -S, --suffix=SUFFIX          override the usual backup suffix\n\
 "), stdout);
       fputs (_("\
-      --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY\n\
-      --no-target-directory    treat DEST as a normal file\n\
+  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY\n\
+  -T, --no-target-directory    treat DEST as a normal file\n\
   -u, --update                 move only when the SOURCE file is newer\n\
                                  than the destination file or when the\n\
                                  destination file is missing\n\
@@ -387,7 +385,8 @@ main (int argc, char **argv)
 
   errors = 0;
 
-  while ((c = getopt_long (argc, argv, "bfiuvS:V:", long_options, NULL)) != -1)
+  while ((c = getopt_long (argc, argv, "bfit:uvS:TV:", long_options, NULL))
+        != -1)
     {
       switch (c)
        {
@@ -412,9 +411,6 @@ main (int argc, char **argv)
        case 'i':
          x.interactive = I_ASK_USER;
          break;
-       case NO_TARGET_DIRECTORY_OPTION:
-         no_target_directory = true;
-         break;
        case REPLY_OPTION:
          x.interactive = XARGMATCH ("--reply", optarg,
                                     reply_args, reply_vals);
@@ -422,7 +418,7 @@ main (int argc, char **argv)
        case STRIP_TRAILING_SLASHES_OPTION:
          remove_trailing_slashes = 1;
          break;
-       case TARGET_DIRECTORY_OPTION:
+       case 't':
          if (target_directory)
            error (EXIT_FAILURE, 0, _("multiple target directories specified"));
          else
@@ -436,6 +432,9 @@ main (int argc, char **argv)
            }
          target_directory = optarg;
          break;
+       case 'T':
+         no_target_directory = true;
+         break;
        case 'u':
          x.update = 1;
          break;
@@ -470,8 +469,8 @@ main (int argc, char **argv)
     {
       if (target_directory)
        error (EXIT_FAILURE, 0,
-              _("Cannot combine --target-directory "
-                "and --no-target-directory"));
+              _("Cannot combine --target-directory (-t) "
+                "and --no-target-directory (-T)"));
       if (2 < n_files)
        {
          error (0, 0, _("extra operand %s"), quote (file[2]));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]