have是bash中的关键字吗?或者bash完成脚本使用的语言不是bash?
have gcc &&
_gcc()
{这是很常见的。请参阅:grep "have .* &&" /etc/bash_completion.d/*
我找不到任何关于我看过的bash完成教程的信息,我在man bash中也找不到任何信息。在谷歌上搜索“有”也很困难。我在哪里可以找到关于这方面的文档?
我猜这与确保PATH中存在gcc有关
编辑:是。/etc/bash_completion包含:
have()
{
unset -v have
# Completions for system administrator commands are installed as well in
# case completion is attempted via `sudo command ...'.
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
have="yes"
}发布于 2012-10-14 01:05:48
have和_have只是在基本bash_completion文件中定义的两个函数。在这两者之间,它们在内置的type命令周围形成一个包装器,以确定特定的命令/程序是否可用。
# This function checks whether we have a given program on the system.
#
_have()
{
# Completions for system administrator commands are installed as well in
# case completion is attempted via `sudo command ...'.
PATH=$PATH:/usr/sbin:/sbin:/usr/local/sbin type $1 &>/dev/null
}
# Backwards compatibility for compat completions that use have().
# @deprecated should no longer be used; generally not needed with dynamically
# loaded completions, and _have is suitable for runtime use.
have()
{
unset -v have
_have $1 && have=yes
}https://stackoverflow.com/questions/12874920
复制相似问题