Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move push_timer to measure command substitution timing too #10466

Merged
merged 1 commit into from May 3, 2024

Conversation

Accurate0
Copy link
Contributor

Description

I've moved the push timer to happen before where command substitution seems to occur, works correctly with the simple repro described on the ticket:

image

Fixes #9100

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

src/parse_execution.rs Outdated Show resolved Hide resolved
@@ -1672,6 +1672,8 @@ impl<'a> ParseExecutionContext {
job.internal_job_id,
);

// Start the timer here to ensure command substitution is measured
let _timer = push_timer(job.wants_timing());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the behavior change looks good (bash does the same) although I think we should consolidate the two calls to push_timer() into one. I don't think there is a reason to treat "simple blocks" specially here.
Then we can also get rid of JobProperties::wants_timing.
Once we support timing background functions we would want to add something similar back

Copy link
Contributor Author

@Accurate0 Accurate0 May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fair, I made some changes, but it feels a little weird.

it maintains the current behavior of time begin; echo -n (sleep 1); end & returning timing even though timing a background job is an error, since the block isn't run as a background job

not sure if that should be an error too? technically it doesn't do anything wrong since the block isn't backgrounded, but it feels weird syntactically for that to be accepted

ignore that, not a good morning, i understand whats happening now..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what i understand, the timing background rule seems to not apply to blocks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

begin; end & is not supported yet and the & is simply ignored. So it's fine if the time behavior is weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay sure, in that case I think the PR is ready for another review, I don't believe the changes I made differ in behavior for the begin; end & situation

@krobelus krobelus added this to the fish next-3.x milestone May 3, 2024
@krobelus krobelus merged commit 4fa8d95 into fish-shell:master May 3, 2024
6 of 7 checks passed
@Accurate0 Accurate0 deleted the measure-command-subst branch May 3, 2024 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

builtin time does not measure command substitutions
3 participants