Add support for fish_trace variable to trace execution

This adds support for `fish_trace`, a new variable intended to serve the
same purpose as `set -x` as in bash. Setting this variable to anything
non-empty causes execution to be traced. In the future we may give more
specific meaning to the value of the variable.

The user's prompt is not traced unless you run it explicitly. Events are
also not traced because it is noisy; however autoloading is.

Fixes #3427
This commit is contained in:
ridiculousfish
2019-10-18 18:08:22 -07:00
parent dd1f8489a7
commit a7f1d2c0c7
15 changed files with 189 additions and 6 deletions

View File

@@ -44,6 +44,7 @@
#include "reader.h"
#include "redirection.h"
#include "signal.h"
#include "trace.h"
#include "wutil.h" // IWYU pragma: keep
/// File descriptor redirection error message.
@@ -899,6 +900,12 @@ static bool exec_process_in_job(parser_t &parser, process_t *p, std::shared_ptr<
// which depends on the redirection being evaluated before the pipe. So the write end of the
// pipe comes first, the read pipe of the pipe comes last. See issue #966.
// Maybe trace this process.
// TODO: 'and' and 'or' will not show.
if (trace_enabled(parser)) {
trace_argv(parser, nullptr, p->get_argv_array().to_list());
}
// The IO chain for this process.
io_chain_t process_net_io_chain = j->block_io_chain();
if (pipes.write.valid()) {