summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-10-17 21:31:45 +0000
committerJim Meyering <jim@meyering.net>1999-10-17 21:31:45 +0000
commit77def80003fd0fa8d2f97a728a13ff15b6495ea1 (patch)
treec4c8a1638bda2cd91d6f004c31ec87d46a286071 /src
parent96018007df1178ba6ce14c8e001e46c0004cc3ab (diff)
downloadcoreutils-77def80003fd0fa8d2f97a728a13ff15b6495ea1.tar.xz
Convert --backup to take an optional argument.
Deprecate --version-control (-V) in comments. (usage): Remove mention of --version-control. (main): Make -V warn then fall through into --backup case. [--backup case]: Handle optional arg.
Diffstat (limited to 'src')
-rw-r--r--src/mv.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/mv.c b/src/mv.c
index 0862b5c6b..877fbcd92 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -84,7 +84,7 @@ char *program_name;
static struct option const long_options[] =
{
- {"backup", no_argument, NULL, 'b'},
+ {"backup", optional_argument, NULL, 'b'},
{"force", no_argument, NULL, 'f'},
{"interactive", no_argument, NULL, 'i'},
{"suffix", required_argument, NULL, 'S'},
@@ -338,21 +338,20 @@ Usage: %s [OPTION]... SOURCE DEST\n\
printf (_("\
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n\
\n\
- -b, --backup make backup before removal\n\
+ -b, --backup[=CONTROL] make backup before removal\n\
-f, --force remove existing destinations, never prompt\n\
-i, --interactive prompt before overwrite\n\
-S, --suffix=SUFFIX override the usual backup suffix\n\
--target-directory=DIR move all SOURCE arguments into directory DIR\n\
-u, --update move only older or brand new non-directories\n\
-v, --verbose explain what is being done\n\
- -V, --version-control=WORD override the usual version control\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
"));
printf (_("\
-The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The\n\
-version control may be set with VERSION_CONTROL, values are:\n\
+The backup suffix is ~, unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\
+The version control may be set with --backup or VERSION_CONTROL, values are:\n\
\n\
none, off never make backups (even if --backup is given)\n\
numbered, t make numbered backups\n\
@@ -372,7 +371,8 @@ main (int argc, char **argv)
int errors;
int make_backups = 0;
int dest_is_dir;
- const char *version;
+ char *backup_suffix_string;
+ char *version_control_string = NULL;
struct cp_options x;
char *target_directory = NULL;
int target_directory_specified;
@@ -387,11 +387,8 @@ main (int argc, char **argv)
cp_option_init (&x);
/* FIXME: consider not calling getenv for SIMPLE_BACKUP_SUFFIX unless
- we'll actually use simple_backup_suffix. */
- version = getenv ("SIMPLE_BACKUP_SUFFIX");
- if (version)
- simple_backup_suffix = version;
- version = NULL;
+ we'll actually use backup_suffix_string. */
+ backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
errors = 0;
@@ -401,8 +398,15 @@ main (int argc, char **argv)
{
case 0:
break;
+
+ case 'V': /* FIXME: this is deprecated. Remove it in 2001. */
+ error (0, 0, _("obsolete option name replaced by --backup"));
+ /* Fall through. */
+
case 'b':
make_backups = 1;
+ if (optarg)
+ version_control_string = optarg;
break;
case 'f':
x.interactive = 0;
@@ -422,10 +426,8 @@ main (int argc, char **argv)
x.verbose = 1;
break;
case 'S':
- simple_backup_suffix = optarg;
- break;
- case 'V':
- version = optarg;
+ make_backups = 1;
+ backup_suffix_string = optarg;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -480,8 +482,12 @@ main (int argc, char **argv)
}
}
+ if (backup_suffix_string)
+ simple_backup_suffix = xstrdup (backup_suffix_string);
+
x.backup_type = (make_backups
- ? xget_version (_("--version-control"), version)
+ ? xget_version (_("--version-control"),
+ version_control_string)
: none);
/* Move each arg but the last into the target_directory. */