Send stderr/stdout messages to function and trap exit signal
问题 Im working on error handling and logging in my bash script. Below I have included a simplified code snippet that exemplify the use case. I want to achieve following in my script: trap exit signals which should trigger onexit() function in the code below stderr and stdout should be sent to the log() function which will make sure to log the output to an log file according to specific log format (simplified in the example below) Issue with current code below: Step 1 is not trapped by onexit