Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Delivered-To: mailing list cygwin@cygwin.com Date: Mon, 15 Aug 2005 21:43:17 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin@cygwin.com To: cygwin@cygwin.com Subject: Re: Programatically finding value of "cygdrive" prefix In-Reply-To: <20050810183616.GA5892@trixie.casa.cgf.cx> Message-ID: References: <42FA4604.8000507@tlinx.org> <20050810183616.GA5892@trixie.casa.cgf.cx> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 10 Aug 2005, Christopher Faylor wrote: > On Wed, Aug 10, 2005 at 11:23:00AM -0700, Linda W wrote: > >Is there a way to find out in a bash script the cygdrive prefix? > >I thought something simple like > > mount -p|tail -1|cut -f1 > >but that incorrectly assumed the fields were tab delimited. > >Since there can be spaces in the cygdrive prefix, I can't > >use space a delimiter, example: > ># mount -p > >Prefix Type Flags > >/cyg drive posix path system binmode > >---- > > There may be a simpler way to do it, but this seems to work: > > mount -p | sed -n '2s/\([^ ]\) *[^ ][^ ]* *[^ ][^ ]*$/\1/p' The main question is: *why* would one want to programmatically find out the cygdrive prefix? If all you want is access '/cygdrive/c' via a POSIX path, wouldn't "cygpath -u c:" do the right thing? In fact, barring special mounts, "cygpath -u c:|sed 's#/c$##'" should do what the OP asked. Alternatively, one could actually use the quotes that "mount -m" produces, via something like mount -m | grep -- --change-cygdrive-prefix | \ xargs bash -c 'while [ $# != 1 ]; do shift; done; echo "$@"' -- HTH, Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha@cs.nyu.edu ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! If there's any real truth it's that the entire multidimensional infinity of the Universe is almost certainly being run by a bunch of maniacs. /DA -- 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/