X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:reply-to:message-id:to:subject
	:in-reply-to:references:mime-version:content-type
	:content-transfer-encoding; q=dns; s=default; b=tLH5zo0iRN0hKw4h
	tBaYOkJkQr/NueWVnftwQHLKPk3Jf5QOX0t3PQGAJZ1Xj9ZtOIoeQYBZd6wMVkVv
	gLeyqiwWZv4caFp3w1LhBnJxVM7X7S7bdSUfjzBtWxuH+h1F/K0+xHdaHmPuQRsW
	bn6g4WoXM+mAYNyzjCSAS86L+0w=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:reply-to:message-id:to:subject
	:in-reply-to:references:mime-version:content-type
	:content-transfer-encoding; s=default; bh=Gsd7qVkGhnpFSh4l8eo+c1
	uLlws=; b=J7i4vVac6gDrGjXyReTUsbV/1T4rB3RRYWZmCzu10W+vmGLYNjHyXY
	eWPDgBds2m1ebYQalDQy/8XC75ceEWG+NUjEqrBOqCuKBJT/VlCgaw64CYzdBJKW
	HFygxuaY0aA240mAbvQFYfbKMQQiFsqIsTaaYUTYeDnCrxpFfVaxQ=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_THEBAT,SPF_SOFTFAIL autolearn=no version=3.3.2
X-HELO: smtp.ht-systems.ru
Date: Mon, 10 Nov 2014 00:58:07 +0300
From: Andrey Repin <anrdaemon@yandex.ru>
Reply-To: cygwin@cygwin.com
Message-ID: <71156572.20141110005807@yandex.ru>
To: "Nellis, Kenneth" <Kenneth.Nellis@xerox.com>, cygwin@cygwin.com
Subject: Re: how to embed shell script within a .BAT file
In-Reply-To: <0D835E9B9CD07F40A48423F80D3B5A702E8379F0@USA7109MB022.na.xerox.net>
References: <0D835E9B9CD07F40A48423F80D3B5A702E8379F0@USA7109MB022.na.xerox.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes

Greetings, Nellis, Kenneth!

> I'm tired of creating pairs of script files:  a clickable .BAT file 
> to invoke my shell script and then my shell script to do the actual
> work.

google: cygwin shell wrapper script
I posted mine in the mailing list not once, and it's not the only available
solution.

> I was wondering if any of the geniuses on this list have come
> up with a way to embed a shell script inside a clickable .BAT file.

It is technically possible to invoke specific processor for a bat file, but no
Cygwin tools understand the necessary syntax. Your only option is to create
proper association(s) for your favorite extensions.

FTYPE unixshell.script="C:\Programs\Cygwin_64\bin\env.exe" -- /bin/cygwrap.sh "%1" %*
ASSOC .sh=unixshell.script
ASSOC .awk=unixshell.script
ASSOC .pl=unixshell.script
ASSOC .whatver=unixshell.script

The wrapper is as simple as

-------->8-------->8-------->8-------->8--------
#!/bin/sh

test -z "$1" && exit 1

/bin/env -- "$(cygpath -au "$1")" "${@:2}"
--------8<--------8<--------8<--------8<--------

Don't forget to add your favorite extensions to PATHEXT, else you won't be
able to run them scripts from CMD.


--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 10.11.2014, <00:51>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

