-
Notifications
You must be signed in to change notification settings - Fork 441
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
How to do something based on exit code of command? #1436
Comments
I suggest writing a bash recipe:
|
@ajeetdsouza Can you use powershell? If you don't have bash, powershell is pretty reasonable. set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
hello:
Write-Host "Hello, world!" |
I did consider using PowerShell / Python / Nushell, but that would mean yet another tool I have to reliably install in CI. I'm currently using an xtask to avoid this, but I'd be willing to migrate if |
This is windows CI? I'm not familiar with what ships natively, but it might already have powershell.exe or pwsh.exe. |
I want CI to run on Windows / macOS / Linux uniformly, and PowerShell is not bundled with macOS / Linux. |
Ahh, I see. Can you open a new issue with your specific use case? I'd have to see exactly what you're trying to do to see if there's a good way to do it. |
How can I do something based on the exit code of a command?
E.g. I have to call an exe that returns 1 upon success and 0 upon failure, and I want to check its exit code
if ["{{COMPILER}}" "/compile:{{DATA_DIR}}/file" /log -ne 1]; then echo "Failed"; else echo "Finished"; fi
Also, in case of error, this exe writes to a file at the path specified by env var
LOGFILE
.But it seems even if I export it (
export LOGFILE := "foo.log"
), the process doesn't see this env var, and thus the file doesn't get written to. Any idea why? When called from a bat file, it works. But not when called from sh via just.This is the bat file I want to replace by my justfile, how can I do the equivalent checks? I'd greatly appreciate any hints :)
The text was updated successfully, but these errors were encountered: