aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Young2016-09-09 14:15:07 -0700
committerEli Young2016-09-28 16:36:11 -0700
commit09c04aa7155ee567f58e2b2285868bb81ce973c9 (patch)
treeb954ab830b5f39f21f3e64edc5763f8691f8b00b
parentff4636bd85b28ebf0d6a94422b76896e4606cf6a (diff)
downloadbrew-09c04aa7155ee567f58e2b2285868bb81ce973c9.tar.bz2
completion: Avoid aliases with `command ls`
If the user has an alias overriding the `ls` command that modifies the output (e.g. `alias ls='ls -F'`), it will cause unexpected characters to appear in completions. Using `command ls` forces the shell to use the command directly, without alias expansion. This also blackholes the stderr of `ls` when used to avoid printing errors during completion if the requisite directory does not exist.
-rw-r--r--completions/bash/brew4
1 files changed, 2 insertions, 2 deletions
diff --git a/completions/bash/brew b/completions/bash/brew
index 67c4c6a3d..b1abe3855 100644
--- a/completions/bash/brew
+++ b/completions/bash/brew
@@ -52,7 +52,7 @@ __brew_complete_formulae() {
__brew_complete_installed() {
local cur="${COMP_WORDS[COMP_CWORD]}"
- local inst="$(ls "$(brew --cellar)")"
+ local inst="$(command ls "$(brew --cellar)" 2>/dev/null)"
COMPREPLY=($(compgen -W "$inst" -- "$cur"))
}
@@ -71,7 +71,7 @@ __brew_complete_versions() {
__brew_complete_logs() {
local cur="${COMP_WORDS[COMP_CWORD]}"
- local logs="$(ls "${HOMEBREW_LOGS:-~/Library/Logs/Homebrew/}")"
+ local logs="$(command ls "${HOMEBREW_LOGS:-${HOME}/Library/Logs/Homebrew/}" 2>/dev/null)"
COMPREPLY=($(compgen -W "$logs" -- "$cur"))
}