macos - bash: 导出: `=' : 不是有效的标识符 -bash: 导出: `=' : 不是有效的标识符

标签 macos bash terminal

终端启动后,我总是收到此消息。

Last login: Wed Apr  6 12:40:06 on console
-bash: export: `=': not a valid identifier
-bash: export: `=': not a valid identifier
-bash: export: `=': not a valid identifier
-bash: export: `=': not a valid identifier
-bash: export: `=': not a valid identifier
-bash: export: `=': not a valid identifier
Mymacs-MacBook-Pro:~ mymac$ 

如何摆脱这个问题?

来自~/.bashrc:

export TOMCAT_HOME=/Library/Tomcat/Home
export IDP_HOME=/Library/SHIBBOLETH-idp/Home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
export M2_HOME=/Users/app/Applications/apache-maven-3.2.5
export PATH=$PATH:$M2_HOME/bin
export JOSSO2_HOME=/Users/app/Applications/josso-ce
export PATH=$PATH:$JOSSO2_HOME/bin
export ANT_HOME=/usr/local/bin/ant
export PATH=$PATH:$ANT_HOME/bin
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

最佳答案

您的 bash 启动脚本之一中的等号周围可能有空格。

查看 .bashrc.bash_profile 中以单词 export 开头的行。 (如果这些没有产生结果,还请查看您可能在 /etc/ 中修改过的 .profile 和 bash 启动文件。)

特别是寻找这种形式:

export foo = bar

并删除 = 周围的空格,使得:

export foo=bar

从交互式 shell 中,您可以看到这种构造会产生您遇到的错误:

$ export foo = bar
bash: export: `=': not a valid identifier

关于macos - bash: 导出: `=' : 不是有效的标识符 -bash: 导出: `=' : 不是有效的标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36458804/

相关文章:

bash - 使用从 bash 中的文件读取的数组并行化 while 循环

bash - 如何在 xargs 命令中使用 >?

java - 运行 GNU 并行 Java 作业

bash - 如何在 shell 脚本中使用通配符连接字符串和变量

JsonConvert 在 Newtonsoft 和 System.Net.Http.Formatting Visual Studio 2017 for Mac 中都存在

regex - 为什么这个正则表达式不能与 grep 一起使用?

c++ - Kext OSDynamicCast 在 OSObject::free 期间失败

python - Linux 终端 : nicely formatted -h output

iphone - Mac 中 iPod/iPhone 的安装点在哪里?

swift - 从应用程序中以编程方式停靠 "Turn Hiding On"