delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/05/09/14:07:44

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <E1B42CFD544FD31193EE0000E87C5CE799B551@mailserver2.mqsoftware.com>
From: Glen Coakley <gcoakley AT mqsoftware DOT com>
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: RE: Get file type information about name returned from "type -p"
Date: Wed, 9 May 2001 13:06:50 -0500
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)

Try:

FOUND_IN_PATH=`find_in_path "foo"`
if [ "$FOUND_IN_PATH != "" ]; then
    # this next line may return more than one result.
    REAL_PATH=`find -perm -+x -maxdepth 1 -name "${TYPE_PATH}*"`
    type -p $REAL_PATH
fi

If you are likely to run into a situation where you may have both 'foo' and
'foo.exe' in the same directory (or you just want a robust script) you will
have to decide how you wish to deal with that. I used find because ls would
return all files even if they were not executable. 

________________________________
Glen Coakley, Sr. Software Engineer
MQSoftware Inc., (763) 543-4845

> -----Original Message-----
> From: Karr, David [mailto:david DOT karr AT cacheflow DOT com]
> Sent: Wednesday, May 09, 2001 12:43 PM
> To: 'cygwin AT cygwin DOT com'
> Subject: Get file type information about name returned from "type -p"
> 
> 
> I'm trying to design some validation scripts for an 
> environment.  One thing
> I want to check for is whether a script named "foo" is 
> earlier in the path
> than a file named "foo.exe".  I already have tools for 
> parsing and searching
> the PATH, but when Cygwin reports that it found a "foo" in my 
> path, I'm
> having trouble figuring out exactly what the file name is, or 
> what kind of
> file it is.  The "type" command gives me a name without an 
> extent, but the
> "file" command doesn't like that.
> 
> --
> Want to unsubscribe from this list?
> Check out: http://cygwin.com/ml/#unsubscribe-simple

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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