bash完成的’have’关键字

前端之家收集整理的这篇文章主要介绍了bash完成的’have’关键字前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
bash中有关键字吗?还是做bash完成脚本使用不是bash的语言?
have gcc &&
_gcc()
{

是很常见.参见:grep“have.*&&” /etc/bash_completion.d/*

我找不到有关我看到的bash完成教程的任何信息,而且我在man bash中找不到任何信息. google也很难“有”.我在哪里可以找到文档?

我猜测它与确保GATH中存在PATH有关吗?

编辑:是的. / 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"
}
have和_have只是在基础bash_completion文件中定义的两个函数.在两者之间,它们围绕内置类型命令形成一个包装器,以确定特定的命令/程序是否可用.
# 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
}

猜你在找的Bash相关文章