Skip to content

Conversation

@rockwotj
Copy link
Contributor

@rockwotj rockwotj commented Jul 31, 2025

The trap wasn't firing before, so rewrite as an if statement.

Fixes: #92

The trap wasn't firing before, so rewrite as an if statement.
@erenon
Copy link
Owner

erenon commented Aug 4, 2025

hi, thanks for the submission. do you know why wasn't the trap firing?

@rockwotj
Copy link
Contributor Author

rockwotj commented Aug 4, 2025

I'm not fully sure, check out this simple reproducer:

#!/usr/bin/env bash
set -ue
# Print output on failure only
logfile="$(mktemp)"
trap 'if (($?)); then cat "$logfile" 1>&2; fi; rm "$logfile"' EXIT

{
  echo "WHAT IS GOING ON HERE" && false
} >"$logfile" 2>&1

Interestingly if I remove set -ue the script works as intended.

@rockwotj
Copy link
Contributor Author

rockwotj commented Aug 4, 2025

Specifically it's the set -e that is causing issues.

In Bash, set -e (also written as set -o errexit) makes the script exit immediately if any command returns a non-zero exit status—which typically indicates an error.

I don't have enough bash fu to know why that causes the issues...

@rockwotj
Copy link
Contributor Author

rockwotj commented Aug 6, 2025

Ping @erenon

@rockwotj
Copy link
Contributor Author

rockwotj commented Aug 8, 2025

Ping @erenon

@dotnwat
Copy link

dotnwat commented Aug 8, 2025

this fixes the problem for me

@rockwotj
Copy link
Contributor Author

Last ping @erenon, thanks!

@erenon
Copy link
Owner

erenon commented Aug 15, 2025

Thanks! merging.

@erenon erenon merged commit b239941 into erenon:master Aug 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

example output nothing

3 participants