-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🙏🏻 [feat/req] suppress annoying "Terminate batch job (Y/N)?" for shimmed deno scripts (Windows) #9873
Comments
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Not stale |
@ry , if you're interested, I've prototyped an enhanced shim that fixes (or works around) this, #9871, and #9874. The shim avoids the "Terminate batch job (Y/N)?" prompt but still leaves a pair of CTRL-C characters displayed when interrupting the shim (not perfect but much less annoying). Likely, this can be fixed if signal handlers are implemented for Windows (see #9995). This is automatic for any Windows script installed with the shim enhancement. If you want to look at the shim, you can install a CLI application with
deno install -A https://deno.land/x/[email protected]/src/dxi.ts
dxi -A https://deno.land/x/[email protected]/eg/args.ts |
At least up to Deno 1.8.1, any shimmed Deno script under Windows will prompt with "Terminate batch job (Y/N)?" when terminated with a
CTRL-C
interrupt. I suggest thatdeno install ...
create a BAT/CMD file with the construction@goto #_undefined_# 2>NUL || @title %COMSPEC% & @deno ...
. This exploits a known CMD quirk:@goto #_undefined_# 2>NUL
terminates the BAT/CMD script but only after executing the rest of the currently parsed code block. This executes the@deno ...
portion in command line context (instead of batch context), so that there is no batch script to terminate. And so, the "Terminate batch job (Y/N)?" prompt is avoided.Notably, this construction also protects against a possible future problem related to a CMD shell bug. Exiting a batch script via fall-thru,
exit ERROLEVEL
, orexit /B ERRORLEVEL
does NOT return ERRORLEVEL as the process exit code unless the BAT/CMD file is executed with acall BAT_FILE
command. The ERRORLEVEL is set and returned to the parent shell correctly, but the process exit code is not. There's more detail, some references, and an alternate solution in my commit forpl2bat
, which is a similar command wrapper forperl
.It's a "possible future problem" because the current shim takes advantage of another countervailing CMD quirk which does pass the ERRORLEVEL out as the process exit code if and only if the command executing the target executable is the last command in the last parsable unit of the BAT/CMD file. If the shim is ever changed to have another code parse unit after the
@deno ...
execution line, then the process exit code will not be set correctly unless the shim is called usingcall SHIM_NAME
, which cannot be expected.The
title %COMSPEC%
command is included in order to work-around the fact that using this prevents the caller from resetting the window title to a prior value which can lead to ever-expanding window titles. I think it's a minor inconvenience for the benefits gained: both the suppression of "Terminate..." and correct process exit values, no matter how the script is called.yarn
has adopted this construction.[1] MSFT terminal ~ Disable "Terminate batch job (Y/N)?" discussion
The text was updated successfully, but these errors were encountered: