Change /S switch behavior

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Aug 23, 2010
110
2
#1
The current behavior of /S switch is that it blocks the Break signal entirely, leaving subsequently started programs with no way to receive it unless they reinstall the handler themselves.
At the same time, if started without /S switch, TCC captures Break even if it was sent to the other program, and asks the same "Do you want to break?" question CMD asking.
Both behaviors are undesirable, when TCC is used as a wrapper for other programs.
I suggest to change /S switch behavior from "explicit block" to "pass through except a handler is explicitly installed (with ON BREAK …)".
 
#4
... even if it was sent to the other program ..." question
I'm not sure what that means, AnrDaemon. In a given console, all processes that haven't turned off break handling or inherited turned-off break handling will get a break signal.

What is the scenario in which you find break handling inadequate?
 
Aug 23, 2010
110
2
#5
A simple .sh script doing "sleep 10" started through this wrapper can't be interrupted by Ctrl+C. Only with Ctrl+Break, which is an entirely different beast.
Code:
@SET PROMPT=@$S$P$_
@ECHO OFF

IF "%~1" == "--install" GOTO :SETUP
IF "%~1" == "" GOTO :BANNER

SET OLDPATH=%[PATH]
SET _CBIN=%@RTRIM[\,%@PATH[%@FULL["%~0"]]]
SET PATH=%[_CBIN]
DO _path IN /T";" /L %[OLDPATH]
  IFF "%[_path]" != "%[_CBIN]" THEN
    SET PATH=%[PATH];%[_path]
  ENDIFF
ENDDO
UNSET OLDPATH _CBIN _path

SET ENV=%@PATH[%@FULL["%~0"]]env.exe
SET CMDNAME=%@EXECSTR[cygpath.exe -u "%~1"]
SHIFT

SET LANG=%@REREPLACE[^(\w+)\..+?(@.+)?$,\1.UTF-8\2,%[LANG]]
"%[ENV]" -- "%[CMDNAME]" %$
QUIT %?

:BANNER
ECHO Cygwin script wrapper.
ECHO Usage:
ECHO.
ECHO   %@FILENAME["%~0"] script [parameters]
ECHO   %@FILENAME["%~0"] --install [.ext ...]
ECHO.
ECHO The ".sh" extension is always registered on install.
QUIT

:SETUP

FTYPE unixshell.script="%[ComSpec]" /S /C "%@FULL["%~0"]" "%%1" %%*
SHIFT
DO EXT IN /L .sh %$
  IFF "%@LEFT[1,%[EXT]]" == "." THEN
    ASSOC %[EXT]=unixshell.script
  ENDIFF
ENDDO
 
#6
Can't you

1. not use /S

and

2. put "ON BREAK ECHOS" in your wrapper?

Is "Do you want to break?" the exact text? I have never seen that from TCC. I have only seen "Cancel batch job V:\ianalyze.btm ? (Y/N/A) :".
 
Aug 23, 2010
110
2
#9
From my PoV, it's not only usual, but an actually wanted behavior for anybody deploying TCC-RT on large scale.
You know your scripts work, and you don't want them interrupted by accident, but underlying programs may have a use for non-destructive break for their own purposes, or you may have a specific idea for that same key, which you implement using an actual ON BREAK handler, rather than plugging a NOOP stub in every script.
 
#10
I suspect "ON BREAK ..." **is** an actual handler ... TCC continues to receive CTRL_C and does what you say instead of the default action.

The wrapper you posted seems to handle the type "unixshell.script". How many other script types need handling? If there are many, then you still must write them. Typing "on break rem" instead of "/S" hardly seems like tedium.
 
Aug 23, 2010
110
2
#11
Yes, "ON BREAK" is an actual handler. Except it doesn't work with /S switch. Plus what I've mentioned earlier.

Yes, this wrapper handles one of the more important bridges in my system, as it covers the gap between native Windows environment and Cygwin.
There's less important stuff like native PHP CLI SAPI wrapper and related scripts wrappers (phar, composer, …). And more stuff like that, to remove rough edges and small inconveniences of daily Windows usage.