mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-11 09:04:01 +03:00
boot/init: Fix System.which logic
- A missing program in a single directory shouldn't error out - A program missing from all directories should return nil
This commit is contained in:
parent
e3c0bf815d
commit
dc63801179
@ -77,10 +77,13 @@ module System
|
|||||||
|
|
||||||
# Discovers the location of given program name.
|
# Discovers the location of given program name.
|
||||||
def self.which(program_name)
|
def self.which(program_name)
|
||||||
ENV["PATH"].split(":").each do |path|
|
(ENV["PATH"] or "").split(":").each do |path|
|
||||||
full = File.join(path, program_name)
|
full = File.join(path, program_name)
|
||||||
return full if File.stat(full).executable? && !File.directory?(full)
|
if File.exists?(full) && !File.directory?(full) && File.stat(full).executable? then
|
||||||
|
return full
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.write(file, contents)
|
def self.write(file, contents)
|
||||||
|
Loading…
Reference in New Issue
Block a user