-
Notifications
You must be signed in to change notification settings - Fork 8.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
cmd: add environment variable to disable/enable 'Terminate batch job (Y/N)?' confirmation #217
Comments
@paulcam206 as the cmd guru, he'll probably have more thoughts on the matter. I really highly doubt that we could just add an env var to disable this, but it is an interactive-only scenario, so it might be possible... |
Thanks for responding Mike! Any specific reason why checking a flag would be so difficult? Looking forward to seeing what @paulcam206 thinks. |
Honestly, changing cmd.exe at all is a bit terrifying. You can't be sure who in the world is actually depending on that behavior for some reason or another. |
it's possible that this could be done with something like a new |
Ack @zadjii-msft - not proposing to change the default, so should only affect people who've explicitly set some very long string. @paulcam206 thanks! I'm not sure about how
Then press |
I don't think anyone is disagreeing with you, @mikemaccana, that this would be a five minute development change to read that environment variable and change the behavior of It's just that from our experience, we know there's going to be a 3-24 month bug tail here where we get massive investigation callbacks by some billion dollar enterprise customer who for whatever reason was already using the environment variable we pick for another purpose. Their script that they give their rank-and-file folks will tell them to press Ctrl+C at some point in the batch script to do whatever happens, it will do something different, those people will notice the script doesn't match the computer anymore. They will then halt the production line and tell their supervisor. The supervisor tells some director. Their director comes screaming at their Microsoft enterprise support contract person that we've introduced a change to the OS that is costing them millions if not billions of dollars in shipments per month. Our directors at Microsoft then come bashing down our doors angry with us and make us fix it ASAP or revert it, we don't get to go home at 5pm to our families or friends because we're fixing it, we get stressed the heck out, we have to spin up servicing potentially for already shipped operating systems which is expensive and headache-causing...etc. We can see this story coming a million miles away because it has happened before with other 'tiny' change we've been asked to make to I would just ask you to understand that I would highly recommend that Gulp convert to using PowerShell scripts and that if such an issue exists with PowerShell, that we get their modern, supported, and better-engineered platform to support the scenario. I don't want you to sit around waiting for |
oh god I'm having ptsd flashbacks just reading that |
yep |
@ALL - @miniksa @zadjii-msft and @paulcam206 are not kidding - the unexpected impact of even the smallest change to Cmd has resulted in calamities, misfortune, lost-weekends and evenings, stress and unnecessary turmoil. Cmd is in maintenance mode. It isn't being deprecated or removed - in fact, I doubt it'll EVER be removed from Windows, but do understand that Cmd is extremely fragile and difficult to change. I keep saying it, and now that PowerShell is available almost everywhere - even Linux & macOS - it's more true than ever: If you're writing Windows Command-Line scripts today, they should be PowerShell scripts wherever possible |
Thanks @bitcrazed. I appreciate the testimony directly from the horse's mouth - I've submitted a PR to one of the many node projects that use |
It seems to me that cmd scripts are generally used in the place of exe symlinks and shebang scripts, which PowerShell is not a good replacement for - if you switch out For this type of thing, we're pretty much stuck with something in |
Powershell is just as good as cmd here. If you're calling |
Well, relevant to this thread, adding the setlocal option is just as good and addresses my concerns also - then all the projects that use cmd scripts this way just add another line at the top. It still requires projects to opt into this behavior, and it's not compatible with older versions of Windows (well, it's compatible, just ignored), but it seems like the best way to do this to me. Doesn't break any other cmd scripts assuming
With all the recent console improvements and WSL, I think there's a possibility of seeing alternate shells on Windows in the future. Cmd may be in maintenance mode, but people still use it too, so I'm not a huge fan of this assumption. Personally I'd really like to see the setlocal option, regardless of how projects choose to handle this. |
It's true. For example, perl wraps all scripts installed from cpan with a few lines of batch code loading perl executable using its
|
@bitcrazed |
@parkovski |
Any progress on this issue? |
We're not going to make changes to cmd.exe to support this scenario. |
Okay, I understand this. Then I found another project, https://github.com/sgraham/cmdEx :( |
@Jack-Works, we are not in the business of developing or propagating unofficial hacks to our software. If you figure something out, more power to you. But we can't help you there. @be5invis, I'm sure the Powershell team would be happy to accept your feedback and improve their product. They are the Microsoft team that has funding for the interactive shell space. |
As everyone else says, the fix for this is moving from While we wait for peopel to start distributing |
I agree with the problem with using powershell here instead of cmd; which I agree would be ideal, except it's far too slow in its initialization time. Even more unfortunately the new pwsh is even slower to initialize. This is something I opened an issue about, but the situation is not likely to be improved PowerShell/PowerShell#6443. Startup latency: 500 ms is way too long for a script, hence I'm not sure the solution to use ps1 is actually reasonable. Here's the script to test start up latency > function time($block) {
$sw = [Diagnostics.Stopwatch]::StartNew()
&$block
$sw.Stop()
$sw.Elapsed
}
> time {powershell -NoProfile -c exit}
> time {cmd-NoProfile -c exit} |
This comment has been minimized.
This comment has been minimized.
It appears like nobody wants to approach I struggle to come up with even a contrived scenario where the proper Ctrl+C handling (especially behind a feature flag) could possibly break any legacy scripts. OTOH, I can think of a magnitude of cases where the current behavior causes annoyances and harm. E.g., when the following batch file is executing and I hit Ctrl+C trying to stop it, the infamous
For a more convincing example, speak to this person: Luckily, there's new When time allows, I'm going to explore this options, like I did to address another controversial behavior, paste-with-formatting-by-default. |
This specific issue came in through Feedback Hub as well and I spent some time reproducing it. When I use conhost.exe, the first time I run the contrived script and do Ctrl+C twice, it exits properly. But subsequent runs, it deletes at the second one anyway. And when through Terminal... it just immediately goes to the second state and deletes. So you've hit my interest further and I will be pulling this particular case out into a separate bug to figure out why the state changes and differs. EDIT: MSFT:36733663 |
Canceling the batch termination prompt uses no as the default answer, and thus the script continues to run. In particular, |
If MSFT is still watching this... what's the likelihood of being able to add a stub-specific replacement, and a new default entry to PATHEXT? I'm thinking the
If it's part of windows, runs very fast, doesn't alter |
Notably, |
@zadjii-msft can you hear the people chanting " One option is to break cmd.exe, forcing all shims to be authored anew. Because the prompt is kind of on the journey there already.
Yeah. But like those people will keep using Windows, as much as you break it for them, but the people in this thread will keep switching to macOS. Kind of apples to oranges. It's been 5 years. |
You're heard, for sure. But we're not planning on touching If you want a modern, updated shell on Windows, you should try out PowerShell 7. Or clink. Or yori. |
This would make a super interesting blog post (which you could point people to any time they ask this again) -- maybe ping Raymond Chen? :D |
I use https://frippery.org/busybox/
Would it be possible to release the source of I got you, thanks for the kind note. |
Sadly, many popular CLI/DevOps tools (Node.js, NPM, Chromium build, etc) already use CMD on Windows, and that's not gonna change, they won't switch to PowerShell. The fear of changing CMD to actually terminate upon Ctrl+C is not only irrational, but also dangerous. E.g., like I mentioned previously in this thread, the following will delete all .gif files, when I franticly press Ctrl+C two times while trying to stop it. It's just beyond my comprehension. @echo off
echo About to delete *.gif.
pause
del /q *.gif At least, it it possible to make the second Ctrl+C act as What do you think about that, @zadjii-msft? |
I understand why you are terrified of changing anything in But:
That way, people who want to make this prompt go away, can create the new registry key/value. It is rather difficult to conceive of a way in which the above change could possibly break anything. If the registry key/value isn't set, it behaves identically to at present. If setting it breaks something, the solution is to remove that registry setting. |
Bad idea. It will affect all cmd.exe instances. Better, for example, to extend |
This comment has been minimized.
This comment has been minimized.
@skissane said:
With these words, you explain exactly why this change is so insidiously dangerous. |
Can it get any worse than data loss, caused by the existing behavior, when it simply continues if you hit Ctrl+C twice? Someone deleted the whole database! 🥲 As is, it's not just annoying, it's dangerous enough already. |
I don't disagree, but somebody, somewhere, is depending on this behaviour. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I can see how changing the default behavior of cmd or its Failing that, please at least make |
(migrated from PowerShell/PowerShell#7080 per @BrucePay's suggestion)
When I cancel a
cmd
script with Ctrl C, the following dialog pops up:I understand why this exists, but I'd also like the option to disable it, so cancelling cancels immediately. Judging by Stack Overflow, I'm not the only one
So a request: could we have an environment variable to control this?
The text was updated successfully, but these errors were encountered: