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 X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Fri, 6 Sep 2002 09:56:07 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: "Watts, Simon (UK)" cc: "'cygwin AT cygwin DOT com'" Subject: Re: cygpath -s behaviour In-Reply-To: <4F055774D458D51195BC000347246B39E80394@xcguk001.inri.co.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 6 Sep 2002, Watts, Simon (UK) wrote: > Just spend a merry lunchtime tracking this behaviour down (it would be > cruel to call it a bug): > > Recap: > cygpath -[mw]s "DIR" > echos the file/directory DIR in shortened windows format (ie, mangles to > 8.3 format). > > If a component part of "DIR" is not in 8.3 format, and does not exist in the > directory structure, then (I presume) 'cygpath' cannot obtain the mangled > form. The upshot is that cygpath returns nothing. It may set an error > state, I havent checked. > > It would be useful if this was mentioned in the man page or '--help'. > > Is there any more useful behaviour? All I am really trying to do in using > the '-s' option is to mangle any componts of the path containing spaces > (writing cross-platform scripts here...). > > What about an option to mangle only those elements of a path which (a) exist > and (b) contain spaces? Which version of cygwin do you have installed? The latest cygpath should, theoretically, print a message to stderr AND return an error code if unable to get the short path (winsup/utils/cygpath.cc:161): DWORD len = GetShortPathName (filename, buf, MAX_PATH); if (len == 0 && GetLastError () == ERROR_INVALID_PARAMETER) { fprintf (stderr, "%s: cannot create short name of %s\n", prog_name, filename); exit (2); } With similar tests every time GetShortPathName is called. Are you losing your stderr, by any chance, e.g. 'cygpath -ws $PATH 2>/dev/null'? As for mangling only the parts of the path that contain spaces, try something like perl -e 'local $_=$ARGV[0];while(/ /){s,^(.*/)([^/]* [^/\n]*),$a=`cd "$1" && /bin/cygpath -ws "$2"`;chomp($a);$1.$a,e};print "$_\n"' or, to pipe the path in, perl -pe 'while(/ /){s,^(.*/)([^/]* [^/\n]*),$a=`cd "$1" && /bin/cygpath -ws "$2"`;chomp($a);$1.$a,e}' You can also check the return code of cygpath in the script if you wish, to filter out the paths that don't have a short name. Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! It took the computational power of three Commodore 64s to fly to the moon. It takes a 486 to run Windows 95. Something is wrong here. -- SC sig file -- 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/