X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_YG X-Spam-Check-By: sourceware.org Message-ID: <4C892C60.6040704@bopp.net> Date: Thu, 09 Sep 2010 13:50:08 -0500 From: Jeremy Bopp User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Windows-style pathname does not work as command - why? References: <4C7FE2C2 DOT 8060104 AT fgm DOT com> <4C7FE938 DOT 6060806 AT redhat DOT com> <20100909102041 DOT 0531f7b5 AT snapdragon> In-Reply-To: <20100909102041.0531f7b5@snapdragon> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 On 9/9/2010 11:20 AM, Morgan Gangwere wrote: > on Thu, 02 Sep 2010 12:13:12 -0600, Eric Blake <4C7FE938 DOT 6060806 AT redhat DOT com> > attacked their terminal with > [stuff relating to Win32 paths] > > Here's a sed script I use to get around that... Put this in your script (or > ~/.bashrc) and enjoy > > function wintocyg { > if [ "x${$1}" == "x" ]; then > return 1 > fi > echo $1 | sed 's/\([a-zA-Z]\)\:/\/cygdrive\/\1/g;s:\\:/:g' > } > > This: > - checks that there is an argument. > - Converts that argument using a sed script that looks for a drive letter, :\ > and converts that into a Cygdrive path. This works for root level stuff > ("d:\") and for deeply nested things (like d:\ping\me_with\a hundred boxes > of\liquor). > > Pretty Simple Stuff, but its a pain. I've used this for a while now. > > I know its a hack but its /works/. You could easily make it escape ' '* but I'm > assuming you're calling it using "`wintocyg mypath`" ( /always/ escape your > paths ) Actually, this function only works if the user has the default cygdrive prefix. This can and often *is* changed, however. Fortunately, the Cygwin developers have had your back on this for a very long time. Use the cygpath program to convert all your paths. It safely handles conversions both to and from POSIX for both absolute and relative paths, can convert to short form DOS paths (e.g C:\Progra~1\...), supports paths with arbitrary whitespace, can provide many well known paths such as the user's Desktop directory, can be run by Windows-native programs, and more. -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple