Skip to content
Snippets Groups Projects
Commit 09c04aa7 authored by Eli Young's avatar Eli Young
Browse files

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.
parent ff4636bd
No related branches found
No related tags found
No related merge requests found
......@@ -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"))
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment