linux shell 工作目录不存在,bash – Shell脚本认为运行cd时目录不存在

我有一个

shell脚本(我将其导入.bashrc),它允许我从任何地方跳转到我的项目目录.

cdp(){

proj="~/dev/projects/$@/"

builtin cd $proj

}

_my_cdp()

{

local cur opts

cur="${COMP_WORDS[COMP_CWORD]}"

opts=$(ls ~/dev/projects/)

COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )

}

complete -o nospace -F _my_cdp cdp

问题是,第3行的CD说:

bash: cd: ~/dev/projects/jsonparse/: No such file or directory

这是完整的控制台输出,显示错误并证明目录存在.

amflare:~$cd dev/projects/ (go to dir)

amflare:~/dev/projects$ls -al (look at contents)

total 68

drwxrwxr-x 17 www-data amflare 4096 Dec 29 13:11 .

drwxrwxr-x 4 amflare amflare 4096 Dec 6 17:32 ..

drwxrwxr-x 3 www-data amflare 4096 Dec 22 17:33 bot

drwxrwxr-x 3 www-data amflare 4096 Dec 20 15:17 jsonparse

drwxrwxr-x 3 www-data amflare 4096 Dec 28 19:58 magic

drwxrwxr-x 2 www-data amflare 4096 Nov 11 14:42 test

amflare:~/dev/projects$cd (go to home)

amflare:~$cdp (run autocomplete)

bot jsonparse magic test

amflare:~$cdp jsonparse (pick target)

bash: cd: ~/dev/projects/jsonparse/: No such file or directory

amflare:~$(still in home)

我已经尝试了所有我能想到的东西以及google为其他发行版回馈的一些东西(我在Ubuntu Gnome 16.04上).无论我做什么,shell脚本都不会承认〜/ dev / projects /中存在任何内容.另外,当我在.bashrc本身有函数时,它不起作用,所以我不认为这是一个子shell问题.如果您需要更多信息,请与我们联系.谢谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值