Skip to content

fix(gcc): explicitly check existence of the commands #772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ _parse_help()
(
case $cmd in
-) exec cat ;;
*) _comp_dequote "$cmd" && LC_ALL=C "$ret" ${2:---help} 2>&1 ;;
*) _comp_dequote "$cmd" && type -- "$ret" &>/dev/null && LC_ALL=C "$ret" ${2:---help} 2>&1 ;;
esac
) |
while read -r line; do
Expand Down Expand Up @@ -1149,7 +1149,7 @@ _parse_usage()
(
case $cmd in
-) exec cat ;;
*) _comp_dequote "$cmd" && LC_ALL=C "$ret" ${2:---usage} 2>&1 ;;
*) _comp_dequote "$cmd" && type -- "$ret" &>/dev/null && LC_ALL=C "$ret" ${2:---usage} 2>&1 ;;
esac
) |
while read -r line; do
Expand Down Expand Up @@ -1822,7 +1822,7 @@ _bashcomp_try_faketty()
{
if type unbuffer &>/dev/null; then
unbuffer -p "$@"
elif script --version 2>&1 | command grep -qF util-linux; then
elif type script &>/dev/null && script --version 2>&1 | command grep -qF util-linux; then
# BSD and Solaris "script" do not seem to have required features
script -qaefc "$*" /dev/null
else
Expand Down
8 changes: 4 additions & 4 deletions completions/gcc
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ _gcc()
complete -F _gcc gcc{,-5,-6,-7,-8} g++{,-5,-6,-7,-8} g77 g95 \
gccgo{,-5,-6,-7,-8} gcj gfortran{,-5,-6,-7,-8} gpc &&
{
if cc --version 2>/dev/null | command grep -q GCC ||
if type cc &>/dev/null && cc --version 2>/dev/null | command grep -q GCC ||
[[ $(_realcommand cc) == *gcc* ]]; then
complete -F _gcc cc
else
complete -F _minimal cc
fi
if c++ --version 2>/dev/null | command grep -q GCC ||
if type c++ &>/dev/null && c++ --version 2>/dev/null | command grep -q GCC ||
[[ $(_realcommand c++) == *g++* ]]; then
complete -F _gcc c++
else
complete -F _minimal c++
fi
if f77 --version 2>/dev/null | command grep -q GCC ||
if type f77 &>/dev/null && f77 --version 2>/dev/null | command grep -q GCC ||
[[ $(_realcommand f77) == *gfortran* ]]; then
complete -F _gcc f77
else
complete -F _minimal f77
fi
if f95 --version 2>/dev/null | command grep -q GCC ||
if type f95 &>/dev/null && f95 --version 2>/dev/null | command grep -q GCC ||
[[ $(_realcommand f95) == *gfortran* ]]; then
complete -F _gcc f95
else
Expand Down