bug-coreutils
[Top][All Lists]
Advanced

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

[PATCH] touch: deprecate --file option: equivalent to --reference (-r)


From: Jim Meyering
Subject: [PATCH] touch: deprecate --file option: equivalent to --reference (-r)
Date: Mon, 09 Feb 2009 11:49:27 +0100

touch's --file option (synonym of --reference) was marked for removal in 2006,
but touch never warned about it, so I've pushed the date out to 2010
and made it so now using --file evokes a warning.

>From ed85df444a92a64bd63e85404719df99afb7381e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 9 Feb 2009 11:44:17 +0100
Subject: [PATCH] touch: deprecate --file option: equivalent to --reference (-r)

* src/touch.c: Mark long-undocumented --file for removal in 2010.
(main): Warn upon use of --file.
---
 src/touch.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/touch.c b/src/touch.c
index bbc9c60..3d6d9fa 100644
--- a/src/touch.c
+++ b/src/touch.c
@@ -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;
--
1.6.2.rc0.173.g5e148




reply via email to

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