From 7129cc01bc72f6a163b1edc6629237241f6030c5 Mon Sep 17 00:00:00 2001 From: Santhanagopalan Krishnamoorthy Date: Wed, 14 Aug 2024 13:57:02 -0600 Subject: [PATCH] Update BinaryFinder to expand ~ to unix location --- .../com/askimed/nf/test/util/BinaryFinder.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/askimed/nf/test/util/BinaryFinder.java b/src/main/java/com/askimed/nf/test/util/BinaryFinder.java index 4da0d081..58547e9f 100644 --- a/src/main/java/com/askimed/nf/test/util/BinaryFinder.java +++ b/src/main/java/com/askimed/nf/test/util/BinaryFinder.java @@ -54,11 +54,16 @@ public BinaryFinder envPath() { if (envPath != null && !envPath.isEmpty()) { String[] paths = envPath.split(":"); for (String path : paths) { - String binary = FileUtil.path(path, name); - if (new File(binary).exists()) { - location = binary; - return this; - } + // Handle the tilde expansion + if (path.startsWith("~")) { + path = path.replaceFirst("~", System.getProperty("user.home")); + } + + String binary = FileUtil.path(path, name); + if (new File(binary).exists()) { + location = binary; + break; // Stop searching once the binary is found + } } }