Permalink
Browse files

program_exists? now checks if the file path is executable.

Also move program_exists? near program_in_path
  • Loading branch information...
1 parent eed91f9 commit 7c19d6ab108ad976fea9b1eb0b7bd558468e8f54 @jordansissel committed Feb 10, 2014
Showing with 8 additions and 10 deletions.
  1. +8 −10 lib/fpm/util.rb
View
@@ -30,6 +30,13 @@ def program_in_path?(program)
return envpath.select { |p| File.executable?(File.join(p, program)) }.any?
end # def program_in_path
+ def program_exists?(program)
+ # Scan path to find the executable
+ # Do this to help the user get a better error message.
+ return program_in_path?(program) if !program.include?("/")
+ return File.executable?(program)
+ end # def program_exists?
+
def default_shell
shell = ENV["SHELL"]
return "/bin/sh" if shell.nil? || shell.empty?
@@ -77,16 +84,7 @@ def safesystem(*args)
return success
end # def safesystem
- def program_exists?(program)
- # Scan path to find the executable
- # Do this to help the user get a better error message.
- if !program.include?("/") and !program_in_path?(program)
- return false
- end
- return true
- end # def program_exists?
-
-# Run a command safely in a way that captures output and status.
+ # Run a command safely in a way that captures output and status.
def safesystemout(*args)
if args.size == 1
args = [ ENV["SHELL"], "-c", args[0] ]

0 comments on commit 7c19d6a

Please sign in to comment.