bash .bash_profile 别名:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25319631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.bash_profile aliases: command not found
提问by Matt LaRose
I cannot get my .bash_profile aliases to work on my Mac OSX Terminal. I created a .bash_profile file in my ~/ directory, then wrote two lines:
我无法让我的 .bash_profile 别名在我的 Mac OSX 终端上工作。我在 ~/ 目录中创建了一个 .bash_profile 文件,然后写了两行:
echo bash profile has loaded
alias prof=“open ~/.bash_profile”
I saved and entered in Terminal command:
我保存并输入终端命令:
. ~/.bash_profile
Terminal displayed:
终端显示:
bash profile has loaded
-bash: alias: /Users/kennethlarose/.bash_profile”: not found
I've been reading up on alias profiles, and I believe my syntax is valid. I know the profile is sourcing because it displays the echo, but Terminal will show the same 'not found' message no matter what command I save in the alias. Does anybody know what else I can try?
我一直在阅读别名配置文件,我相信我的语法是有效的。我知道配置文件正在采购,因为它显示回声,但无论我在别名中保存什么命令,终端都会显示相同的“未找到”消息。有人知道我还能尝试什么吗?
回答by that other guy
Let's ask shellcheck!
问问shellcheck吧!
In .bash_profile line 2:
alias prof=“open ~/.bash_profile”
^-- SC1015: This is a unicode double quote. Delete and retype it.
There's your problem. OS X has turned your double quotes into fancy slanted quotes that bash doesn't recognize. If you're programming, you may want to disable "smart quotes".
那是你的问题。OS X 已经把你的双引号变成了 bash 无法识别的花哨的斜引号。如果您正在编程,您可能需要禁用“智能引号”。