wrappers: Don't rely on "readlink -f"

Older macOS versions (macOS 12.2 at least) don't support this
option, while newer macOS versions do support it (macOS 12.6).

The solution is based on https://stackoverflow.com/a/1116890/3115956,
but simplified for this usecase.
This commit is contained in:
Martin Storsjö committed 2023-05-23 11:23:27 +03:00
1 parent fc5d2c9b21
commit 3184cb2060
3 files changed
+33 -3

No files matched your search

+11 -1
View File
@@ -14,7 +14,17 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
DIR="$(cd "$(dirname $(readlink -f "$0"))" && pwd)"
get_dir() {
target="$1"
while [ -L "$target" ]; do
cd "$(dirname "$target")"
target="$(readlink "$(basename "$target")")"
done
cd "$(dirname "$target")"
pwd
}
DIR="$(get_dir "$0")"
BASENAME="$(basename "$0")"
TARGET="${BASENAME%-*}"
EXE="${BASENAME##*-}"
+11 -1
View File
@@ -14,7 +14,17 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
DIR="$(cd "$(dirname $(readlink -f "$0"))" && pwd)"
get_dir() {
target="$1"
while [ -L "$target" ]; do
cd "$(dirname "$target")"
target="$(readlink "$(basename "$target")")"
done
cd "$(dirname "$target")"
pwd
}
DIR="$(get_dir "$0")"
export PATH="$DIR":"$PATH"
BASENAME="$(basename "$0")"
+11 -1
View File
@@ -14,7 +14,17 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
DIR="$(cd "$(dirname $(readlink -f "$0"))" && pwd)"
get_dir() {
target="$1"
while [ -L "$target" ]; do
cd "$(dirname "$target")"
target="$(readlink "$(basename "$target")")"
done
cd "$(dirname "$target")"
pwd
}
DIR="$(get_dir "$0")"
export PATH="$DIR":"$PATH"
if [ "$1" = "-f" ]; then