Skip to content

[Process] Use command -v/where before manual searching #45035

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

Closed
wants to merge 1 commit into from

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Jan 15, 2022

Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

I caught this "missing" feature when reviewing symfony/flex#845 (comment) . I can't think of a reason not to use where/command -v first in the executable finder - this will probably work for 90% of the cases?

@nicolas-grekas
Copy link
Member

Does this provide anything? Because if it can't yield different results than what the current logic does, it's better to save spawning a process.

@wouterj
Copy link
Member Author

wouterj commented Jan 16, 2022

The comment I referenced was the main inspiration for this PR. Given Flex has two places now where we find an executable using which/command -v instead of the executable finder, I felt it was a sign about what executable finder should be doing.

Also, I had the feeling that scanning file existence across all available paths might be heavier than spawning a short process, but I haven't had any software studies nor did I do benchmarking so that's just feelings.

In general, I always lean on using the official tools to do a job. In this case, the executable finder's job is to find an executable that can be used with the Process component. So if there is some shell doing something with a differently named PATH var, our replicated logic would break, but using the official tool wouldn't. I was under the impression that Fish' user path feature didn't use the PATH var, but after some testing I now see that user path vars are automatically part of PATH (probably because of BC reasons).

TL;DR: given we forgot to use this class in Flex and Flex used something different, I wonder about the relevance of the current executable finder. But no hard feelings if this PR is closed :)

@nicolas-grekas
Copy link
Member

I explained the reasoning of the current logic in the flex thread, which is based on consistency.

My opinion here is: If it ain't broken, don't fix it.

@wouterj wouterj closed this Jan 16, 2022
@wouterj wouterj deleted the process-finder branch January 18, 2022 14:37
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.

3 participants