Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3F178545.9020603@fangorn.ca> Date: Fri, 18 Jul 2003 01:27:33 -0400 From: Mark Blackburn User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: [PATCH] : make cygpath use multiple filename arguments References: <3F170CE6 DOT 2040903 AT fangorn DOT ca> In-Reply-To: Content-Type: multipart/mixed; boundary="------------070006060109050502020305" --------------070006060109050502020305 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Picky, picky... Rolf Campbell wrote: > What about filenames with spaces in them? Wouldn't the output be > ambiguous? > > Mark Blackburn wrote: > >> Dunno if anybody will find this useful or not: >> >> Currently if you say: >> >> # cygpath -w /usr /lib >> >> you get a usage error. With my patch you get: >> >> # cygpath -w /usr /lib >> c:\cygwin\usr c:\cygwin\lib >> >> Mark. >> >> >> ------------------------------------------------------------------------ >> >> Index: utils/cygpath.cc >> =================================================================== >> RCS file: /cvs/src/src/winsup/utils/cygpath.cc,v >> retrieving revision 1.28 >> diff -u -p -r1.28 cygpath.cc >> --- utils/cygpath.cc 12 Jun 2003 20:40:58 -0000 1.28 >> +++ utils/cygpath.cc 17 Jul 2003 20:36:17 -0000 >> @@ -479,7 +479,7 @@ doit (char *filename) >> } >> } >> >> - puts (buf); >> + printf ("%s", buf); >> } >> >> static void >> @@ -675,11 +675,16 @@ main (int argc, char **argv) >> if (output_flag) >> dowin (o); >> >> - if (optind != argc - 1) >> + if (optind > argc - 1) >> usage (stderr, 1); >> >> - filename = argv[optind]; >> - doit (filename); >> + for (int i=optind; argv[i]; i++) { >> + if (i != optind) >> + printf(" "); >> + filename = argv[i]; >> + doit (filename); >> + } >> + printf("\n"); >> } >> else >> { >> >> > > > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Problem reports: http://cygwin.com/problems.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ > --------------070006060109050502020305 Content-Type: text/plain; name="cygpath.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cygpath.patch" ? aoeu Index: utils/cygpath.cc =================================================================== RCS file: /cvs/src/src/winsup/utils/cygpath.cc,v retrieving revision 1.28 diff -u -p -r1.28 cygpath.cc --- utils/cygpath.cc 12 Jun 2003 20:40:58 -0000 1.28 +++ utils/cygpath.cc 18 Jul 2003 05:20:07 -0000 @@ -30,6 +30,7 @@ static int shortname_flag, longname_flag static int ignore_flag, allusers_flag, output_flag; static int mixed_flag; static const char *format_type_arg; +static int quote_output; static struct option long_options[] = { {(char *) "absolute", no_argument, NULL, 'a'}, @@ -479,7 +480,10 @@ doit (char *filename) } } - puts (buf); + if (quote_output && strchr(buf,' ') != NULL) + printf("\"%s\"", buf); + else + printf ("%s", buf); } static void @@ -675,11 +679,21 @@ main (int argc, char **argv) if (output_flag) dowin (o); - if (optind != argc - 1) + if (optind > argc - 1) usage (stderr, 1); - filename = argv[optind]; - doit (filename); + if (optind == argc - 1) + quote_output = 0; + else + quote_output = 1; + + for (int i=optind; argv[i]; i++) { + if (i != optind) + printf(" "); + filename = argv[i]; + doit (filename); + } + printf("\n"); } else { --------------070006060109050502020305 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --------------070006060109050502020305--