Title: Windows: Provide an option to disable search in CWD on `shutil.which` · Issue #91558 · python/cpython · GitHub
Open Graph Title: Windows: Provide an option to disable search in CWD on `shutil.which` · Issue #91558 · python/cpython
X Title: Windows: Provide an option to disable search in CWD on `shutil.which` · Issue #91558 · python/cpython
Description: I would like to search for an executable in the PATH but not from the current working directory (cwd). By default, as documented in shutil.which, it prepends the cwd before PATH, so it's not possible to get the expected executable. For e...
Open Graph Description: I would like to search for an executable in the PATH but not from the current working directory (cwd). By default, as documented in shutil.which, it prepends the cwd before PATH, so it's not possib...
X Description: I would like to search for an executable in the PATH but not from the current working directory (cwd). By default, as documented in shutil.which, it prepends the cwd before PATH, so it's not po...
Opengraph URL: https://github.com/python/cpython/issues/91558
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Windows: Provide an option to disable search in CWD on `shutil.which`","articleBody":"I would like to search for an executable in the PATH but not from the current working directory (`cwd`). By default, as documented in [`shutil.which`](https://docs.python.org/3/library/shutil.html#shutil.which), it prepends the cwd before PATH, so it's not possible to get the expected executable.\r\n\r\nFor example, I have a `whoami.exe` in the cwd but I would like to get the one from the system32 directory; there's no way to do so using `shutil.which`.\r\n```py\r\n\u003e\u003e\u003e import shutil\r\n\u003e\u003e\u003e shutil.which('whoami')\r\n'.\\\\whoami.EXE'\r\n```\r\nI think it makes sense for that to be the default behaviour since that's how it is on Windows. I would like to have a parameter to disable this behaviour in `shutil.which`.\r\n\r\nThanks!","author":{"url":"https://github.com/naveen521kk","@type":"Person","name":"naveen521kk"},"datePublished":"2022-04-15T05:41:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/91558/cpython/issues/91558"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d4816100-009a-e141-621f-f63c2153db1d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA2E:21F5A3:1BAF08:2725D2:6968C13E |
| html-safe-nonce | fcc487cc947424a9962bfd3d60d39f182de1d1dde9f7d8016aceb001795a60d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTJFOjIxRjVBMzoxQkFGMDg6MjcyNUQyOjY5NjhDMTNFIiwidmlzaXRvcl9pZCI6IjM0MzI2MDY0OTgzMDkwNjI5NzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f65ef9cc2b8e0552106ad44abf3f43a24b088145793788f4322540b45a0dbd0f |
| hovercard-subject-tag | issue:1205285225 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/91558/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4282162abed646ad5b4f42ce8487484c663d54de3b945bb7acc64f78decbbd95/python/cpython/issues/91558 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4282162abed646ad5b4f42ce8487484c663d54de3b945bb7acc64f78decbbd95/python/cpython/issues/91558 |
| og:image:alt | I would like to search for an executable in the PATH but not from the current working directory (cwd). By default, as documented in shutil.which, it prepends the cwd before PATH, so it's not possib... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | naveen521kk |
| hostname | github.com |
| expected-hostname | github.com |
| None | fdc7c66bd36a6c12eb8e771e806db863266e573fc299e77f27505a768d4f8a98 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3223a6503d318917691422cdadfbe16cd8fb21e5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width