The script
command logs an entire shell session to file. This is great, but when reviewing the session I'd like to be able to see the exit code of each command that I ran.
Is it possible to capture this in the script
logs? Ideally without displaying it to the user of the script
session, but that would be acceptable if necessary.
Example of running script:
me:~ oliverlade$ script
Script started, output file is typescript
bash-3.2$ echo "hello"
hello
bash-3.2$ true
bash-3.2$ false
bash-3.2$ exit
exit
Script done, output file is typescript
The contents of the log file:
me:~ oliverlade$ cat typescript
Script started on Sun Aug 7 13:02:43 2016
bash-3.2$ echo "hello"
hello
bash-3.2$ true
bash-3.2$ false
bash-3.2$ exit
exit
Script done on Sun Aug 7 13:03:03 2016
What I'd like it to be:
me:~ oliverlade$ cat typescript
Script started on Sun Aug 7 13:02:43 2016
bash-3.2$ echo "hello"
hello
(exit 0)
bash-3.2$ true
(exit 0)
bash-3.2$ false
(exit 1)
bash-3.2$ exit
exit
Script done on Sun Aug 7 13:03:03 2016