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

bash – 当路径作为命令输入时,cd到目录(而不是“foo是目录”错

发布时间:2020-12-15 18:32:05 所属栏目:安全 来源:网络整理
导读:我讨厌当bash给我“呃
我讨厌当bash给我“呃!”一种错误:
foo$./bar
-bash: ./bar: is a directory

我曾经喜欢AmigaOS shell,其中“执行”目录只是意味着将其设置为当前目录:

foo$./bar
bar$

在bash中有可能吗? (当然没有无限数量的别名.)

Bash 4.0具有autocd选项.

从Official FAQ:

There is a new ‘autocd’ option that,
when enabled,causes bash to attempt
to `cd’ to a directory name that is
supplied as the first word of a simple
command.

另外,至少早在2.0之前,请查看man bash中任何版本的CDPATH环境变量.它允许您通过在列出的目录中搜索cd命令中指定的目录来缩短cd命令.

(编辑:李大同)

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

    推荐文章
      热点阅读