Skip to content

Commit 39815b8

Browse files
(maint) only check builtin_command? for posix
The `builtin_command?` only is useful in posix, where the `type` function is defined. Windows Powershell does not have `type` defined.
1 parent 13ccc8b commit 39815b8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/facter/custom_facts/core/execution/base.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ def log_stderr(msg, command, logger)
138138
logger.debug(format(STDERR_MESSAGE, command, msg.strip))
139139
end
140140

141+
# optional function to be defined in subclass if necessary
141142
def builtin_command?(command)
142-
output, _status = Open3.capture2("type #{command}")
143-
output.chomp =~ /builtin/ ? true : false
143+
nil
144144
end
145145
end
146146
end

lib/facter/custom_facts/core/execution/posix.rb

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def search_paths
1111
ENV['PATH'].split(File::PATH_SEPARATOR) + DEFAULT_SEARCH_PATHS
1212
end
1313

14+
def builtin_command?(command)
15+
output, _status = Open3.capture2("type #{command}")
16+
output.chomp =~ /builtin/ ? true : false
17+
end
18+
1419
def which(bin)
1520
if absolute_path?(bin)
1621
return bin if File.executable?(bin) && FileTest.file?(bin)

0 commit comments

Comments
 (0)