Change your command to:
mysql test < <(bzip2 -dc < dump.sql.bz2)
Using a process substitute instead of a pipeline makes the command a simple command from the Bash perspective, which is the level of detail at which the DEBUG trap and the $BASH_COMMAND built-in variable.
Background
The DEBUG signal (pseudo) by design works at the level of simple commands, like $BASH_COMMAND .
bzip2 -dc < dump.sql.bz2 | mysql test bzip2 -dc < dump.sql.bz2 | mysql test is a pipeline made up of a few simple commands.
Therefore, your trap statement cannot do what you want with the pipeline.
The immediate task is to get what you want with a compound command (for example, a while or a group of commands ( { ...; ...; } ) or a list of commands (simple commands or pipelines connected to operators ; && || & ) , - use set -v , which intercepts the entire stderr command before executing it, but I donβt know how to control the formatting of this output.
source share