delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/16/16:55:07

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Tue, 16 Aug 2005 16:54:50 -0400
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Programatically finding value of "cygdrive" prefix
Message-ID: <20050816205450.GA16323@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
References: <42FA4604 DOT 8000507 AT tlinx DOT org> <20050810183616 DOT GA5892 AT trixie DOT casa DOT cgf DOT cx> <Pine DOT GSO DOT 4 DOT 61 DOT 0508152130380 DOT 9560 AT slinky DOT cs DOT nyu DOT edu> <1124222681 DOT 29974 DOT 37 DOT camel AT p450>
Mime-Version: 1.0
In-Reply-To: <1124222681.29974.37.camel@p450>
User-Agent: Mutt/1.5.8i

In the spirit of this soon-to-be-week-old thread I think I've come up
with the ultimate way to find the cygdrive prefix.  It meets all of the
requirements that have been set out so far:

1) It is more complicated than my original solution

2) It is much slower than my original solution

3) It is not guaranteed to provide 100% correct results

4) Hitting CTRL-C while running it will leave stray subst'ed drives
around that you may not want (an added bonus).

Here it is:

  #!/bin/bash
  for f in c d e f g h i j k l m n o p q r s t u v w x y z; do
      subst "$f": "$SYSTEMROOT" >/dev/null 2>&1 || continue
      cd "$f":; cd ..
      cygdrive=$(pwd)
      subst /d "$f":
      break
  done
  echo "$cygdrive"

HTH.

cgf

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019