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

bash完成的黑名单程序

发布时间:2020-12-15 22:57:52 所属栏目:安全 来源:网络整理
导读:Fedora附带了“gstack”和一堆“gst-”程序,当我试图快速输入我的git别名时,这些程序一直出现在我的bash完成中.它们当然和/usr/bin一起安装在其他一千个程序中,所以我不能只从我的PATH中删除它们的目录.在 Linux中是否有任何方法可以将这些特定程序列入黑名
Fedora附带了“gstack”和一堆“gst-”程序,当我试图快速输入我的git别名时,这些程序一直出现在我的bash完成中.它们当然和/usr/bin一起安装在其他一千个程序中,所以我不能只从我的PATH中删除它们的目录.在 Linux中是否有任何方法可以将这些特定程序列入黑名单以便完成?

我已经尝试过FIGNORE和GLOBIGNORE环境变量,但它们不起作用,看起来它们只是在您输入命令后才能完成文件.

解决方法

2016年,Bash为此推出了一个选项.我将在 zuazo年复制 this newer answer的文字:

这是相当新的,但在Bash 4.4中您可以设置EXECIGNORE变量:

aa. New variable: EXECIGNORE; a colon-separate list of patterns that
will cause matching filenames to be ignored when searching for commands.

从the official documentation开始:

EXECIGNORE

A colon-separated list of shell patterns (see 07004) defining the list of filenames to be ignored by command search using
PATH. Files whose full pathnames match one of these patterns are not
considered executable files for the purposes of completion and command
execution via PATH lookup. This does not affect the behavior of the [,
test,and [[ commands. Full pathnames in the command hash table are
not subject to EXECIGNORE. Use this variable to ignore shared library
files that have the executable bit set,but are not executable files.
The pattern matching honors the setting of the extglob shell option.

例如:

$EXECIGNORE=$(which pytest)

或者使用Pattern Matching:

$EXECIGNORE=*/pytest

(编辑:李大同)

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

    推荐文章
      热点阅读