delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/04/22:02:20

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <3CFD7154.A7213B4A@swcp.com>
Date: Tue, 04 Jun 2002 20:03:00 -0600
From: Lynn Wilson <lynn AT swcp DOT com>
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin <cygwin AT cygwin DOT com>
Subject: run batch w/o .bat?
X-Spam-Status: No, hits=0.5 required=10.0 tests=SUBJ_ENDS_IN_Q_MARK,TO_LOCALPART_EQ_REAL version=2.21
X-Virus-Scanned: by amavisd-milter (http://amavis.org/)

In my $HOME I have a bin directory that I populate with symbolic links to all
*.bat files in my $PATH.  Here is a bash script to populate it...

enjoy.
Lynn

-----------------------
#!/bin/bash

Origpath=$PWD
for Testpath in ${PATH//:/' '} ; do

if [ -d $Testpath ] ; then
    cd $Testpath
    Basepath="$(pwd | cygpath --unix -f -)"
    Batfiles=$( ls -1 *.bat *.bash  2> /dev/null )

    for Batfile in $Batfiles; do
        Realfile="${Basepath}/${Batfile}"
        Linkname=${Batfile##/*/}
        Linkname=${Linkname%%.*}

        Linkname=~/bin/$Linkname
        if [ -e $Linkname ] ; then
            echo Warning... link to $Realfile exists > /dev/stderr
        else
            echo linking $Realfile --- $Linkname
            ##rm -f $Linkfile
            ln -s "$Realfile" "$Linkname"
        fi
    done
fi

done

echo "removing link for ~/bin/pgp"
rm ~/bin/pgp

cd $OrigPath

exit 0

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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