我有一些窗口,使用Cygwin,试图通过.bashrc文件永久地设置JAVA_HOME。
.bashrc:
export PATH="$JAVA_HOME/bin:$PATH"
export JAVA_HOME=$JAVA_HOME:"/cygdrive/c/Program Files (x86)/Java/jdk1.7.0_05"
. bash_profile:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
cygwin运行:
-bash: $'\377\376if': command not found
-bash: $'then\r': command not found
: No such file or directorysu//.bashrc
-bash: /cygdrive/c/Users/jhsu//.bash_profile: line 3: syntax error near unexpected token `fi'
-bash: /cygdrive/c/Users/jhsu//.bash_profile: line 3: `fi'
我不确定我从教程中获取的命令是针对另一个系统的,还是我遗漏了一个步骤。或者空格导致我的命令不能正常运行。
我看过很多类似的问题,但我还没有找到一个问题完全有我的错误。
我的家乡路:
$ echo $HOME
/cygdrive/c/Users/jhsu
$ echo ~
/cygdrive/c/Users/jhsu/
所以我认为文件应该放在正确的位置。
如果你正在使用最新的Cygwin(例如1.7),你也可以在第一个非注释行上用下面的行开始你的.bashrc和.bash_profile:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
(set -o igncr) 2>/dev/null && set -o igncr; # this comment is needed
这将强制bash忽略Windows行分隔符中使用的回车(\r)字符。
见http://cygwin.com/ml/cygwin-announce/2010-08/msg00015.html。
如果你正在使用最新的Cygwin(例如1.7),你也可以在第一个非注释行上用下面的行开始你的.bashrc和.bash_profile:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
(set -o igncr) 2>/dev/null && set -o igncr; # this comment is needed
这将强制bash忽略Windows行分隔符中使用的回车(\r)字符。
见http://cygwin.com/ml/cygwin-announce/2010-08/msg00015.html。