aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/commands.rb
diff options
context:
space:
mode:
authorMartin Afanasjew2015-10-15 17:41:07 +0200
committerMike McQuaid2015-10-15 19:26:27 +0100
commit21d804eeb8824e29a152388a7d1483d4dac45640 (patch)
tree86c121cb85de2694634465f376c5765b9d5f3aea /Library/Homebrew/cmd/commands.rb
parentb5ec74c3f6b32cdd25b8051c1b47b3594aa1fb90 (diff)
downloadbrew-21d804eeb8824e29a152388a7d1483d4dac45640.tar.bz2
commands: ensure external commands are executable
For consistency with `brew command` and the logic in `brew.sh` (both use `which` to find/validate an external command), we need to filter files that are not executable. Otherwise `brew commands` and thus bash completion will offer commands that will produce an error when attempting to use them. Closes Homebrew/homebrew#44999. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew/cmd/commands.rb')
-rw-r--r--Library/Homebrew/cmd/commands.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/commands.rb b/Library/Homebrew/cmd/commands.rb
index 30034ec20..d7734e132 100644
--- a/Library/Homebrew/cmd/commands.rb
+++ b/Library/Homebrew/cmd/commands.rb
@@ -38,6 +38,7 @@ module Homebrew
def external_commands
paths.flat_map { |p| Dir["#{p}/brew-*"] }.
+ select { |f| File.executable?(f) }.
map { |f| File.basename(f, ".rb")[5..-1] }.
reject { |f| f =~ /\./ }.
sort