mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
Add short names -t and -T for --target-directory
and --no-target-directory options, respectively. (NO_TARGET_DIRECTORY_OPTION, TARGET_DIRECTORY_OPTION): Remove. All uses changed to 'T' and 't', respectively. (long_options, main, usage): Add -t and -T as aliases for --target-directory and --no-target-directory, respectively.
This commit is contained in:
1 parent
1b32f828b0
commit
9f3628bd45
3 files changed
+52
-69
No files matched your search
+17
-25
@@ -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 mandatory for short options too.\n\
|
||||
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);
|
||||
|
||||
@@ -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 mandatory for short options too.\n\
|
||||
"), 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
|
||||
@@ -500,6 +489,9 @@ main (int argc, char **argv)
|
||||
}
|
||||
target_directory = optarg;
|
||||
break;
|
||||
case 'T':
|
||||
no_target_directory = true;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
|
||||
@@ -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 mandatory for short options too.\n\
|
||||
-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]));
|
||||
|
||||
Reference in new issue
Block a user