Don't time --no-execute

This made some output for non-execution.

See #977.
This commit is contained in:
Fabian Homborg 2020-02-17 11:38:21 +01:00
parent 3f5c60e634
commit 5f9c33b50a
3 changed files with 8 additions and 2 deletions

View File

@ -957,7 +957,7 @@ bool exec_job(parser_t &parser, const shared_ptr<job_t> &j, const job_lineage_t
// A false return tells the caller to remove the job from the list.
return false;
}
cleanup_t timer = push_timer(j->flags().has_time_prefix);
cleanup_t timer = push_timer(j->flags().has_time_prefix && !no_exec());
// Get the deferred process, if any. We will have to remember its pipes.
autoclose_pipes_t deferred_pipes;

View File

@ -1214,7 +1214,8 @@ end_execution_reason_t parse_execution_context_t::run_1_job(tnode_t<g::job> job_
// is significantly faster.
if (job_is_simple_block(job_node)) {
tnode_t<g::optional_time> optional_time = job_node.child<0>();
cleanup_t timer = push_timer(optional_time.tag() == parse_optional_time_time);
// If no-exec has been given, there is nothing to time.
cleanup_t timer = push_timer(optional_time.tag() == parse_optional_time_time && !no_exec());
tnode_t<g::variable_assignments> variable_assignments = job_node.child<1>();
const block_t *block = nullptr;
end_execution_reason_t result =

View File

@ -5,6 +5,11 @@ echo "type foo" | $fish -n
echo $status
#CHECK: 0
# Test that it doesn't time non-execution.
echo "time echo foo" | $fish -n
echo $status
#CHECK: 0
# Test that it doesn't check globs.
echo "echo /asfjidhfiusnlkxcnvklxcvlkmcxlv*" | $fish -n
echo $status