delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/04/30/18:28:50

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Eric Blake <ebb9 AT byu DOT net>
Subject: Re: Normalized directory name
Date: Thu, 30 Apr 2009 22:28:19 +0000 (UTC)
Lines: 27
Message-ID: <loom.20090430T222137-118@post.gmane.org>
References: <Pine DOT NEB DOT 4 DOT 64 DOT 0904301631080 DOT 20542 AT panix2 DOT panix DOT com>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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

Tim McDaniel <tmcd <at> panix.com> writes:

> For tidiness, if nothing else, I'd like to get the normalized form, in
> much the same way how, in CMD, I can do
>      E:\>cd cm\buildutil
> and have the prompt become
>      E:\CM\BuildUtil>

In the case of cd, I'm not going to patch bash to do this by default.  However, 
you may be able to figure out how to write a shell function that uses bash's 
case-insensitive globbing to get something close to what you want:

$ shopt -s nocaseglob
$ echo src SRC sr[c] SR[C]
src SRC src src

So, given a name you want to normalize, find a way to rewrite it as a shell 
glob (easiest way to avoid the glob expanding into multiple files is converting 
one letter into a one-byte charset).  Seems like it would be an easy sed script 
to write to do that, which in turn can be wrapped by shell functions.  But 
beware that with cygwin 1.7, you can have directories which are case sensitive, 
in which case the glob may return multiple files.

-- 
Eric Blake




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