Greetings, All!

I think I've finally ironed out most of the issues I had with it. (Infinite
number of arguments, quoting, etc.)
The only known issues that cause script to break seems to be the same as you
would expect with direct script executions - uneven/misplaced quotation marks.

How to use:
Place the attached script as /bin/cygwrap.cmd (placement is important, as the
script working out certain paths relative to its location).
Run the script. Short notice should appear, mentioning usage and registration
process.
Run the script with "--install" option. By default, the script only register
the ".sh" extension. You may list additional extensions after "--install",
space-separated.
F.e.

  cygwrap.cmd --install .pl .py

Then try executing a simple test.sh[1] script with all kind of arguments and
see if there's any significant discrepancy in what you pass to the script and
what is actually interpreted from your input.
Keep in mind, that "="(equality sign) is a parameter separator in CMD, and
parameters containing it must be enclosed in double quotes.

If you want to execute Cygwin scripts from native CMD scripts through this
association, and/or use CMD completion/executable search functions, you will
need to adjust your %PATHEXT% variable to include relevant extensions.
F.e.
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.BTM;.PHP;.SH

If you are not happy with wrapper prepending Cygwin's bin directory to the
%PATH%, i.e. if you already have your path set up to include Cygwin/bin, feel
free to comment out the relevant line from the script.

[1]
#!/bin/sh -x
echo "$PATH"
echo $#: "$@"


-- 
WBR,
Andrey Repin

Sorry for my terrible english...
@SETLOCAL ENABLEEXTENSIONS
@SET PROMPT=@$S$P$_
@ECHO OFF
SET PATH=%~dp0;%PATH%
IF NOT "%~1" == "" GOTO :SETUP

ECHO Cygwin script wrapper.
ECHO Usage:
ECHO.
ECHO   %~nx0 script [parameters ...]
ECHO   %~nx0 --install [ext ...]
ECHO.
GOTO :END

:SETUP
IF NOT "%~1" == "--install" GOTO :WRAP
FTYPE unixshell.script="%~f0" "%%1" %%*
SET EXT=.sh
:ASSOC
ASSOC %EXT%=unixshell.script
SHIFT
SET EXT=%~1
IF "%EXT%" == "" GOTO :END
GOTO :ASSOC

:WRAP
SET ENV=%~dp0env.exe
SET CMDNAME=
SET PARAMS=

FOR /F "usebackq" %%a IN (`cygpath.exe -u "%~1"`) DO (
  SET CMDNAME=%%~a
  SHIFT
)

:PARAMS
SET _tmp=%1
IF .%_tmp% == ."%~1" (
  GOTO :CONCAT
) ELSE (
  IF "%~1" == "" GOTO :EXEC
)

:CONCAT
SET PARAMS=%PARAMS% %1
SHIFT

GOTO :PARAMS

:EXEC
"%ENV%" -- "%CMDNAME%"%PARAMS%

:END
ENDLOCAL 2> NUL:
--
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

Reply via email to