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 }
原文地址:https://www.jb51.cc/bash/383540.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。