From f6b65f0a517c0c1a89dd68d424112c5d9d17ea14 Mon Sep 17 00:00:00 2001 From: Saurabh Kamat Date: Wed, 6 Nov 2024 01:14:02 +0800 Subject: [PATCH] Using Pathname to check for absolute path (#550) Signed-off-by: Saurabh Kamat --- src/cmd/cmdtransport.rb.in | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cmd/cmdtransport.rb.in b/src/cmd/cmdtransport.rb.in index 74d96000b..82d15aba3 100644 --- a/src/cmd/cmdtransport.rb.in +++ b/src/cmd/cmdtransport.rb.in @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'open3' +require 'pathname' # Constants. LIBRARY_VERSION = '@PROJECT_VERSION_FULL@' @@ -31,10 +31,7 @@ class Cmd command = args[0] exe_name = COMMANDS[command] - if exe_name[0] == '/' - # If the first character is a slash, we'll assume that we've been given an - # absolute path to the executable. This is only used during test mode. - else + unless Pathname.new(exe_name).absolute? # We're assuming that the library path is relative to the current # location of this script. exe_name = File.expand_path(File.join(File.dirname(__FILE__), exe_name))