Closed alexschcom closed 2 months ago
I checked and gum log -l fatal hello
indeed returns an error status code. More precisely it returns 1. (See the image)
You should use &&
instead of ;
between your commands. The reason is that &&
ensures the second command only runs if the first command succeeds. This can help prevent potential issues if the first command fails for some reason.
Hm, you're right. I'm still confused though since I use gum log -l fatal
in one of my scripts and it did exit the entire script before. Now it keeps executing (unless chained with &&
, like you said).
Wouldn't it make sense to exit
when encountering a fatal issue? As in:
if [[ -z $1 ]]; then gum log -l fatal "Not enough arguments"; fi
I have tried to checkout the tags v0.13.0 and v0.12.0 and I can't reproduce the behaviour you're talking about. Can you please provide some more details like a version number and a reproducible example of the behaviour you think have changed.
Also you can stop the script by checking if the error code is 1.
I am using version 0.14.1
. I remember before the 0.14.x
update, calling gum log -l fatal
would stop execution of following commands in a script. For example:
gum log -l fatal "Some error occurred"
echo hello
Here, the echo
command would not execute, since gum log -l fatal
would automatically exit the script, as it does in Go files (see here). This makes sense, considering we're dealing with a fatal error. Now, however, it does execute the following commands...
@alexschcom You can add set -e
at the begining of your script to exit immediately if a command fails.
#!/usr/bin/env bash
set -e
gum log -l fatal "Some error occurred"
echo hello
seems to be working on main.
What seems to be working?
on main, not released yet.
Describe the bug Calling
gum log -l fatal <...>
used to return an error status code which would stop execution of further commands.To Reproduce Steps to reproduce the behavior:
gum log -l fatal hello; echo world
echo
.Expected behavior the
log
library callsos.Exit(1)
onlog.Fatal(err)
. Correspondingly, usinggum log -l fatal
should also stop execution of the script.Desktop (please complete the following information):