'有'的bash补全关键字 [英] 'have' keyword for bash completion
问题描述
是有
A在bash关键字?或者做的bash脚本完成使用不来砸语言?
有GCC和放大器;&安培;
_gcc()
{
这是常见的。参见:的grep有*放大器;&安培。 /etc/bash_completion.d / *
我找不到在bash补全教程我见过的任何信息,我无法找到男人庆典
的任何信息。这也是很难谷歌有。我在哪里可以找到这个文件?
我猜它与确保有做的gcc
存在于 PATH
?
编辑:是的。 的/ etc / bash_completion
包含:
有()
{
未设置-v有
对于系统管理员命令#落成的安装,以及在
#结案通过`sudo命令尝试......。
PATH = $ PATH:/ sbin目录:/ usr / sbin目录:在/ usr / local / sbin中输入$ 1安培;>的/ dev / null的&放大器;&安培;
有=YES
}
有
和 _have
只是两种功能在基 bash_completion
文件中定义。在这两者之间,他们周围形成一个包装内置键入
命令来确定某一特定命令/程序可用。
#此功能检查我们是否有系统给定的程序。
#
_有()
{
对于系统管理员命令#落成的安装,以及在
#结案通过`sudo命令尝试......。
PATH = $ PATH:/ usr / sbin目录:/ sbin目录:在/ usr / local / sbin中输入$ 1安培;>的/ dev / null的
}对于使用具有compat的落成#向后兼容性()。
#@德precated不应再使用;通常不需要与动态
#装载落成,并_have适合运行使用。
有()
{
未设置-v有
_have $ 1安培;&安培;有= YES
}
Is have
a keyword in bash? Or do bash completion scripts use a language that is not bash?
have gcc &&
_gcc()
{
It is common. See: grep "have .* &&" /etc/bash_completion.d/*
I could not find any information on the bash completion tutorials I've seen and I could not find any information in man bash
. It's also difficult to google "have". Where do I find documentation on this?
I'm guessing it has to do with making sure that there gcc
exists in the PATH
?
edit: yes. /etc/bash_completion
contains:
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
and _have
are just two functions defined in the base bash_completion
file. Between the two, they form a wrapper around the built-in type
command to determine if a particular command/program available.
# 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补全关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!