I have windows, using Cygwin, trying to set JAVA_HOME
permanently through my .bashrc
file.
.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
running 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'
I am not sure if I took the commands from a tutorial that was meant for another system or if I am missing a step. Or whitespace is causing my commands not to run properly.
I've looked at multiple similar questions but I haven't found one where the question has my error exactly.
My home path:
$ echo $HOME
/cygdrive/c/Users/jhsu
$ echo ~
/cygdrive/c/Users/jhsu/
So I believe the files should be placed in the correct spot.
Resolved with Notepad++ :
1) Menu->Edit->EOL Conversion -> Unix/OSX Format
2) Then Save
Fixed
I am using cygwin and Windows7, the trick was NOT to put the
set -o igncr
into your .bashrc but put the wholeSHELLOPTS
into you environment variables under Windows. (So nothing with unix / cygwin...) I think it does not work from.bashrc
because "the drops is already sucked" as we would say in german. ;-) So mySHELLOPTS
looks like thisFor the Emacs users out there:
This will update the new characters in the file to be unix style. More info on "Newline Representation" in Emacs can be found here:
http://ergoemacs.org/emacs/emacs_line_ending_char.html
Note: The above steps could be made into an Emacs script if one preferred to execute this from the command line.
As per this gist, the solution is to create a
~/.bash_profile
(inHOME
directory) that contains:1. Choice
EditorConfig — is my choice.
2. Relevance
This answer is relevant for March 2018. In the future, the data from this answer may be obsolete.
Author of this answer personally used EditorConfig at March 2018.
3. Limitations
You need to use one of supported IDE/editors.
4. Argumentation
.editorconfig
file 1 time, where I create my project, → I can forget some platform-, style- and IDE-specific problems.5. Example
5.1. Simple
I install EditorConfig plugin for Sublime Text → my text editor. I edit files in Sublime Text.
For example, I have
sashacrlf.sh
file:I run this file in Cygwin:
I create a file
.editorconfig
in same project assashacrlf.sh
.It means, that if you save any file with
.sh
extension in your project in your editor, EditorConfig set UNIX line endings for this file.I save
sashacrlf.sh
in my text editor again. I runsashacrlf.sh
again:I can't get unexpected output in console.
5.2. Multiple file extensions
For example, I want to have UNIX line endings in all files with extensions
.sh
,.bashrc
and.bash_profile
. I add these lines to my.editorconfig
file:Now, if I save any file with
.sh
,.bashrc
or.bash_profile
extension, EditorConfig automatically set UNIX line ending for this file.6. Additional links
For WINDOWS users with Notepad++ (checked with v6.8.3) you can correct the specific file using the option - Edit -> EOL conversion -> Unix/OSX format
And save your file again.
Edit: still works in v7.5.1 (Aug 29 2017)