delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/11/13/09:12:40

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: <C9A98ED35114D31197D000805FEA668E0176E5A5@mucexch.muc.sdm.de>
From: klaus DOT berndl AT sdm DOT de
To: Joerg DOT Schaible AT gft DOT com, cygwin AT sourceware DOT cygnus DOT com
Subject: AW: Ultimative way to start Windows NT/2000 programs from bash
Date: Mon, 13 Nov 2000 15:07:35 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)

> My be you should remove now 95 and 98 from the subject <g>. 

Has been done.

> What about other
> executables or script files identified by PATHEXT ?

Yes, good point! here is the next iteration (the last one i hope :-)

# open any file in the correct program: an associated file-type (see assoc
# and ftype at Windows NT/2000) will be opened with the associated program.
# Not associated filetypes and files which extension is contained in
# $PATHEXT will be opened in the texteditor (here Emacs). Files with
# extension .exe and .com will not be opened!

function open-file-with-w32 () {
    for i in $*; do
        if [ -f "$i" ]; then
            # get the extension only
            erg=`echo $i | sed -e 's|.*\.||g;'`
            # check if we try to open a program
            if [ "$erg" != "exe" ] &&
               [ "$erg" != "EXE" ] &&
               [ "$erg" != "com" ] &&
               [ "$erg" != "COM" ]; then
                # check if we try to open a file with a extension from $PATHEXT
                is_path_ext=`echo "$PATHEXT"\; | grep -i "\.$erg;"`
                if [ "$is_path_ext" == "" ]; then
                    # check if this extension is associated with a w32-program
                    erg=`cmd /x /c assoc ".$erg" 2>/dev/null`
                    if [ "$erg" != "" ]; then
                        # an associtiation exists therefore this call should
                        # theoretically not produce amn error.
                        cmd /x /c start /b `cygpath -w "$i"` 2>/dev/null
                    else
                        # we must open the file with a text editor because
                        # it is not associated.
                        emacs `cygpath -w "$i"`
                    fi
                else
                    # files with a extension contained in $PATHEXT will be
                    # opened with the text editor.
                    emacs `cygpath -w "$i"`            
                fi
            else
                echo "$i is a program!"
            fi
        fi
    done
    unset erg is_path_ext; }
alias o=open-file-with-w32

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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