]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
touch: deprecate --file option: equivalent to --reference (-r)
authorJim Meyering <meyering@redhat.com>
Mon, 9 Feb 2009 10:44:17 +0000 (11:44 +0100)
committerJim Meyering <meyering@redhat.com>
Mon, 9 Feb 2009 10:44:40 +0000 (11:44 +0100)
* src/touch.c: Mark long-undocumented --file for removal in 2010.
(main): Warn upon use of --file.

src/touch.c

index bbc9c60129dc46b5e275ad5acaf3d1c6d3235228..3d6d9fac26becae106eb63a0b2dfba821bcacf26 100644 (file)
@@ -1,5 +1,5 @@
 /* touch -- change modification and access times of files
-   Copyright (C) 87, 1989-1991, 1995-2005, 2007-2008
+   Copyright (C) 87, 1989-1991, 1995-2005, 2007-2009
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -82,7 +82,7 @@ static struct option const longopts[] =
   {"time", required_argument, NULL, TIME_OPTION},
   {"no-create", no_argument, NULL, 'c'},
   {"date", required_argument, NULL, 'd'},
-  {"file", required_argument, NULL, 'r'}, /* FIXME: remove --file in 2006 */
+  {"file", required_argument, NULL, 'r'}, /* FIXME: remove --file in 2010 */
   {"reference", required_argument, NULL, 'r'},
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
@@ -275,6 +275,7 @@ main (int argc, char **argv)
   bool date_set = false;
   bool ok = true;
   char const *flex_date = NULL;
+  int long_idx; /* FIXME: remove in 2010, when --file is removed */
 
   initialize_main (&argc, &argv);
   set_program_name (argv[0]);
@@ -287,7 +288,7 @@ main (int argc, char **argv)
   change_times = 0;
   no_create = use_ref = false;
 
-  while ((c = getopt_long (argc, argv, "acd:fmr:t:", longopts, NULL)) != -1)
+  while ((c = getopt_long (argc, argv, "acd:fmr:t:", longopts, &long_idx)) != -1)
     {
       switch (c)
        {
@@ -311,6 +312,10 @@ main (int argc, char **argv)
          break;
 
        case 'r':
+         if (long_idx == 3)
+           error (0, 0,
+                  _("warning: the --%s option is obsolete; use --reference"),
+                  longopts[long_idx].name);
          use_ref = true;
          ref_file = optarg;
          break;