Get file type information about name returned from "type -p"

Karr, David david.karr@cacheflow.com
Wed May 9 13:03:00 GMT 2001


What is "TYPE_PATH" supposed to be?  Is that just the unsuffixed name of the
program?

I have a feeling that this also will not deal properly with two programs
named "foo" and "foostuff", where the files "foo", "foo.exe", "foostuff",
and "foostuff.exe" exists, and I want to verify that "foo" is before
"foo.exe".

I also don't know why you're ending with "type -p", as AFAIK, that's going
to send it back to "program name" again, instead of "file name", which is
what I need.

-----Original Message-----
From: Glen Coakley [ mailto:gcoakley@mqsoftware.com ]
Sent: Wednesday, May 09, 2001 11:07 AM
To: 'cygwin@cygwin.com'
Subject: RE: Get file type information about name returned from "type
-p"



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.karr@cacheflow.com ]
> Sent: Wednesday, May 09, 2001 12:43 PM
> To: 'cygwin@cygwin.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

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



More information about the Cygwin mailing list