Closed minimalic closed 1 month ago
Yes, I thought the same on my first try on macOS, but I noticed the type
command behaves differently in zsh
(current default on macOS).
If you try it with bash
(default environment in the sake
script) you will notice that type -P which
behaves the same across Unix-Like Systems.
You can test it with a simple script (don't forget to make this script itself executable with chmod u+x script.sh
):
#!/usr/bin/env bash
[ -x "$(command -v which)" ] && echo "executable" || echo "no"
[ -x "$(type -P which)" ] && echo "executable" || echo "no"
I've tested it on latest macOS, Ubuntu, Rocky Linux/RHEL, Fedora. The second command worked on all systems, while the first (actual sake
method) did not.
The problem with command -v which
is the output of an "Alias" instead of direct path on some systems - so the check for executability fails. The type -P which
method should be most compatible alternative - as long as sake
uses bash
shell environment.
Closed in favour of https://github.com/silverstripe/silverstripe-framework/pull/11232
Description
This pull request addresses an issue with the
which
command detection in thesake
script, which failed to accurately detect the presence of thewhich
command across different operating systems. The previous implementation usingcommand -v which
functioned properly on Ubuntu-like distributions but not on others like Rocky Linux/RHEL or Fedora, where it sometimes returned only a command name or a function instead of the full path to the executable.To ensure broader compatibility, especially with non-Debian-based Linux distributions, this fix modifies the command detection logic to use
type -P which
.Manual testing steps
On Linux inside Silverstripe project, run
vendor/bin/sake dev/build
and verify that it executes without the "which command" error.Issues
10682
Pull request checklist