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

which returns directory paths #267

Merged
merged 1 commit into from
Sep 28, 2023
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Sep 28, 2023

  • The following output is incorrect because the results all refer to directories

$ perl which . .. /
/usr/local/sbin/.
/usr/local/sbin/..
/usr/local/sbin//

  • The command "which" is supposed to find files available to execute, not directories
  • Resolve this by adding explicit directory check before checking "-x $path"
  • Style: declare path variables to make code simpler to read

* The following output is incorrect because the results all refer to directories

$ perl which . .. /
/usr/local/sbin/.
/usr/local/sbin/..
/usr/local/sbin//

* The command "which" is supposed to find files available to execute, not directories
* Resolve this by adding explicit directory check before checking "-x $path"
* Style: declare path variables to make code simpler to read
@briandfoy briandfoy self-assigned this Sep 28, 2023
@briandfoy briandfoy added Type: bug an existing feature does not work Priority: low get to this whenever Program: which The which program labels Sep 28, 2023

if (-d $path) {
next;
}
if ($^O eq 'MacOS') {
Copy link
Owner

Choose a reason for hiding this comment

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

Do you know why we'd single out MacOS here? I think this is Mac Classic, which we don't need to support. We don't need to change this for this PR, but it's something to think about. I wonder what happens on Windows, which has a completely different permissions model.

@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Sep 28, 2023
@briandfoy briandfoy merged commit 9b54822 into briandfoy:master Sep 28, 2023
1 check passed
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: which The which program Status: released there is a new release with this fix Type: bug an existing feature does not work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants