-
Notifications
You must be signed in to change notification settings - Fork 410
Fix miri.bat to not exit unconditionally #3715
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
Fix miri.bat to not exit unconditionally #3715
Conversation
|
I implemented it the same as you first, then thought about what I wrote about in my review and changed it to what it is now. But I did not think that |
|
Didn't occur to me, either. || (echo Failed to build miri-script. Is the 'stable' toolchain installed? & exit /b)as you suggested on Zulip also works. Not sure which is "better" stylistically or functionally, so I'll defer to you or others with better batch knowledge on what we want to do to fix it. |
|
I have no batch knowledge :) so I am fine with whatever the Windows Gurus agree upon here.
|
|
But my feeling is that explicit is better than implicit, so the version with parentheses seems more appealing to me. That's also why I used parentheses in the Unix Shell version.
|
|
Seems like a reasonable reason to go that way - switched to @RossSmyth's version (tested locally again to be careful). |
|
As I explained in the review comment, the version with parenthesis and |
|
LGTM though |
|
@rustbot ready |
|
So does the single & here mean sequencing now? Elsewhere you said it means "fork", I guess similar to what it means in Unix - but that would be the wrong meaning here as it would run " echo" and "exit" in parallel, which is not what we want? Or did I misunderstand?
|
|
I do not know which review comment you are referring to, @RossSmyth. Please always add a link when referring to other comments like that :)
|
I was wrong about the meaning of & in batch / cmd... I'm rusty on it (ha)- but I believe @RossSmyth's explanation is right. I'm having a hard time finding any decent official docs for batch files. Powershell is much better documented 😞. cargo +stable build %CARGO_EXTRA_FLAGS% -q --target-dir %MIRI_SCRIPT_TARGET_DIR% --manifest-path %0\..\miri-script\Cargo.toml || echo Failed to build miri-script. Is the 'stable' toolchain installed?
exit /bWhich was definitely not what we wanted. I'll see if I can find a better reference. |
I can't find it either. I thought he meant the discussion in Zulip earlier today, but that doesn't quite make sense in context? Dunno |
|
Here's the not-relevant powershell docs for the powershell version of those operators. But Batch / cmd.exe != powershell. |
|
Ok, finally found the official, 1st party docs... buried in a generic page instead of a nicely searchable
Use to run the command following
This still doesn't make sense to me, unless there's operator precedence involved as we suspected and since c is exit, we didn't run miri-script. But big picture, with the appropriate parentheses to force b and c to run in the failure case, together, either & or && would work, and & is a bit more foolproof because if echo somehow fails, we still should run exit / should not try to run miri-script if the toolchain is missing. Hope that answers the question @RalfJung. |
|
Okay, thanks for checking!
I'm fine with replacing the bat file by a ps1 file, happy to leave that decision to Windows-using folks. I'd prefer not to have both a bat file and a ps1 file though. |
|
☀️ Test successful - checks-actions |
miri.bat
Outdated
| :: return from the script. If not, it will continue execution. | ||
| cargo +stable build %CARGO_EXTRA_FLAGS% -q --target-dir %MIRI_SCRIPT_TARGET_DIR% --manifest-path %0\..\miri-script\Cargo.toml ^ | ||
| || echo Failed to build miri-script. Is the 'stable' toolchain installed? & exit /b | ||
| || echo Failed to build miri-script. Is the 'stable' toolchain installed? && exit /b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this semantically correct for all failure cases.
If the cargo command fails we want the statement to be post-dominated by the exit /b statement. But the current implementation means "only exit if the echo command succeeds."
Basically if echo ever has a write error it will not exit, so I would recommend my Zulip suggestion so that it will always exit in the error case:
| || echo Failed to build miri-script. Is the 'stable' toolchain installed? && exit /b | |
| || (echo Failed to build miri-script. Is the 'stable' toolchain installed? & exit /b) |
|
Oh oops, I never actually finalized the review. I was referring to a comment only I could see. Posted it just for posterity |
The problem with .ps1 files is that by default on Windows, PowerShell scripts are not able to be executed. And some people (such as on corporate computers) cannot configure them to be executable. I think PowerShell is decent, but for scripts to be executable by arbitrary people bat files are the only real choice, or else you lock out people who are unable to run PowerShell scripts. |
That's a fair reason. But then again - is ./miri.bat used outside of dev? if not, there are very few devs who don't have the ability to run powershell, I'd think |
#3703 has a small typo causing it to regress ./miri.bat to not working at all.
This PR fixes it. Tested on Windows 11, with stable toolchain missing as well as installed.
Closes #3714