加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash完成的’have’关键字

发布时间:2020-12-16 01:37:21 所属栏目:安全 来源:网络整理
导读:bash中有关键字吗?还是做bash完成脚本使用不是bash的语言? have gcc _gcc(){ 是很常见.参见:grep“have.*” /etc/bash_completion.d/* 我找不到有关我看到的bash完成教程的任何信息,而且我在man bash中找不到任何信息. google也很难“有”.我在哪里可以找
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
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读