I want the actual command line be logged together with its output.
I routinely execute important commands like this:
PERL5LIB=${PERL5LIB}:/something/extra my-command.pl many arguments which I want to save 2>&1 | tee -a my-command.log
Now my-command.log
contains both stdout
and stderr
of my-command.pl
.
However, it does not contain the actual command line above.
I know of the bash
history file; so, I guess, I could copy from there (or from the terminal) by hand, but this is not a good solution, of course.
I guess I could write a shell function which would accept a command line, echo it, and then execute it, but then I would have to deal with the quoting hell.
I tried set -v
but that appears to ignore redirection.
script
does save the command line (but only if I have start a new shell, not with -c
) but it does not work in the emacs shell interaction buffer and it saves the shell prompt too - including the escape sequences! - to its log file, so it is suboptimal.
script
does not save the command line; for my purposes it is no better thantee -a
.