[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
trap DEBUG after the command but not before the command
From: |
Peng Yu |
Subject: |
trap DEBUG after the command but not before the command |
Date: |
Wed, 6 Nov 2019 02:56:13 +0800 |
Hi,
I'd like a trap similar to DEBUG trap, but run after the command. I
wants to get the exit status as well. Is there something in bash that
can support this? Thanks.
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
trap 'echo $? The running command is: "${BASH_COMMAND[@]}"' DEBUG
echo 'Hello World1!'
$ ./main.sh
0 The running command is: echo 'Hello World1!'
Hello World1!
--
Regards,
Peng
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- trap DEBUG after the command but not before the command,
Peng Yu <=