Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Declined Change /S (/B) switch behavior

Aug
717
10
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 …)".
 
Pardon me, but CMD's /S switch does an entirely different thing.
It is a quotation control for /C and /K switches.
 
... 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?
 
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
 
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) :".
 
Yes, I CAN write "ON BREAK REM" in every wrapper.
In fact, I do.
But it quickly turns into a tedium.
What you want is rather unusual and that sounds like a nearly perfect solution. Maybe a (fourth) special alias "ON_BREAK: would do the job (but you probably wouldn't want it all the time).
 
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.
 
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.
 
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.
 

Similar threads

Back
Top