On Tue, 11 Feb 2003, Max Bowsher wrote:

> Igor Pechtchanski wrote:
> > On Tue, 11 Feb 2003, Newton, Doug wrote:
> >
> >> If this change is what is desired by the majority, that is fine.
> >> BUT, it should have been made clear that the fundamental behaviour
> >> of cygpath had changed.  I have many scripts that no longer work.
> >> Even the jakarata ant tool's start-up script now mangles the
> >> classpath because of this change in behaviour.
> >
> > This change makes the output correct.  I suppose that would be
> > something desired by the majority...
>
> Yet technical correctness has come at the price of usability and
> functionality.
> E.g. You cannot convert to --mixed style from --windows style with --path.

Quite true.

> >> We no longer have the option to run a classpath of unknown format
> >> through cgypath to make sure it is in a known format.  This is the
> >> issue in the jakarta ant tool.  It makes no assumptions on what the
> >> format of the path is -- it immediately converts it to unix
> >> regardless of the current format.
> >
> > It makes an assumption that the format is Windows.  Otherwise,
> > there'd be no need to convert to Unix format...
>
> Of course, if you simply wanted to *ensure* that the path was in unix
> format... you're stuck.

Yes.  I tracked the change to the following cvs commit:
<http://cygwin.com/ml/cygwin-cvs/2002-q4/msg00080.html>, particularly the
"(doit): Do various things to make path output work predictably." part.

> >> Is there another utility that can be used to identify the format of a
> >> classpath?  This will be needed to account for the changed behaviour
> >> in modifying scripts.
> >
> > Umm, 'grep'?  In particular, grep for a ";" or a "\" for a
> > windows-format path...
>
> Which is presumably vaguely what cygpath used to do.
>
> Doug: have you considered making a patch to cygpath to make it behave more
> to your liking (conditional on a command line option if need be), and
> submitting that?
>
> Max.

Umm, since I've opened my mouth on the issue, I'll submit the patch...
        Igor
==========================================================================
ChangeLog:
2003-02-11  Igor Pechtchanski <[EMAIL PROTECTED]>

        * cygpath.cc (doit): Add code to simply ensure the path is
        in the right format.
        (ensure_flag): New static variable.
        (options,long_options): Add 'e' flag.
        (main): Set ensure_flag.

-- 
                                http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_                [EMAIL PROTECTED]
ZZZzz /,`.-'`'    -.  ;-;;,_            [EMAIL PROTECTED]
     |,4-  ) )-,_. ,\ (  `'-'           Igor Pechtchanski
    '---''(_/--'  `-'\_) fL     a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
  -- /usr/games/fortune
Index: winsup/utils/cygpath.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/cygpath.cc,v
retrieving revision 1.25
diff -u -p -r1.25 cygpath.cc
--- winsup/utils/cygpath.cc     31 Oct 2002 02:40:26 -0000      1.25
+++ winsup/utils/cygpath.cc     12 Feb 2003 01:00:16 -0000
@@ -29,6 +29,7 @@ static int path_flag, unix_flag, windows
 static int shortname_flag, longname_flag;
 static int ignore_flag, allusers_flag, output_flag;
 static int mixed_flag;
+static int ensure_flag;
 static const char *format_type_arg;
 
 static struct option long_options[] = {
@@ -53,10 +54,11 @@ static struct option long_options[] = {
   {(char *) "smprograms", no_argument, NULL, 'P'},
   {(char *) "sysdir", no_argument, NULL, 'S'},
   {(char *) "windir", no_argument, NULL, 'W'},
+  {(char *) "ensure", no_argument, NULL, 'e'},
   {0, no_argument, 0, 0}
 };
 
-static char options[] = "ac:df:hilmopst:uvwADHPSW";
+static char options[] = "ac:df:hilmopst:uvwADHPSWe";
 
 static void
 usage (FILE * stream, int status)
@@ -76,6 +78,7 @@ Path conversion options:\n\
   -l, --long-name      print Windows long form of NAME (with -w, -m only)\n\
   -p, --path           NAME is a PATH list (i.e., '/bin:/usr/bin')\n\
   -s, --short-name     print DOS (short) form of NAME (with -w, -m only)\n\
+  -e, --ensure         ensure the path is in the right format (with -p only)\n\
 System information:\n\
   -A, --allusers        use `All Users' instead of current user for -D, -P\n\
   -D, --desktop                output `Desktop' directory and exit\n\
@@ -411,6 +414,27 @@ doit (char *filename)
   int retval;
   int (*conv_func) (const char *, char *);
 
+  if (ensure_flag && path_flag)
+    {
+      if (cygwin_posix_path_list_p (filename) ? unix_flag : windows_flag)
+       {
+         if (windows_flag)
+           {
+             buf = filename;
+             if (shortname_flag)
+               buf = get_short_paths (buf);
+             if (longname_flag)
+               buf = get_long_paths (buf);
+             if (mixed_flag)
+               buf = get_mixed_name (buf);
+             filename = buf;
+           }
+         /* The path is already in the right format.  */
+         puts (filename);
+         exit (0);
+       }
+    }
+
   if (!path_flag)
     {
       len = strlen (filename);
@@ -518,6 +542,7 @@ main (int argc, char **argv)
   else
     prog_name++;
 
+  ensure_flag = 0;
   path_flag = 0;
   unix_flag = 1;
   windows_flag = 0;
@@ -561,6 +586,10 @@ main (int argc, char **argv)
          path_flag = 1;
          break;
 
+       case 'e':
+         ensure_flag = 1;
+         break;
+
        case 'u':
          if (windows_flag || mixed_flag)
            usage (stderr, 1);
@@ -665,6 +694,9 @@ main (int argc, char **argv)
   if (shortname_flag && !windows_flag)
     usage (stderr, 1);
 
+  if (ensure_flag && !path_flag)
+    usage (stderr, 1);
+
   if (!unix_flag && !windows_flag && !mixed_flag && !options_from_file_flag)
     usage (stderr, 1);
 
@@ -741,6 +773,9 @@ main (int argc, char **argv)
                    break;
                  case 'p':
                    path_flag = 1;
+                   break;
+                 case 'e':
+                   ensure_flag = 1;
                    break;
                  case 'D':
                  case 'H':
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to