Email or username:

Password:

Forgot your password?
Top-level
Noah K

@simon if you trap on the pseudo signal EXIT it will kick in on other exit modes too :)

7 comments
Simon Willison

@coderanger Got it - that looks like this: trap cleanup EXIT

Noah K

@hynek @simon to be fair, bash is probably the most poorly documented programming language in existence.

Hynek Schlawack

@coderanger @simon I was gonna quip that Bash is a prime example where ChatGPT is a bad choice because 99% of Bash scripts out there are dangerous, hot garbage.

Noah K

@hynek @simon long ago I worked on an install script that had to work on a half dozen different unixes. It started with a comment like “if you are under 30, please consult an old person before trying any optimizations here”. Because bash on aix vs linux vs macos was such a mess.

Noah K

@simon same idea but trap functionname EXIT, and it will run on any non sigkill exit

Go Up