0

A while ago I was messing around with my Mac settings in Terminal. Since then, I've had to use dos2unix (http://dos2unix.sourceforge.net/) on many files just to be able to run them. This includes files that my team create and push to a shared repository, that I then pull down (for example, bash .sh files).

My bash profile:

export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH

I removed the first line, and restarted my Mac. I still have the same issue.

I have no idea what settings I've changed on my Mac - would anybody know what it could be? I apologise for the vagueness of my issue, I changed the settings long ago!

Ross Ridge
  • 35,323
  • 6
  • 64
  • 105
Daven
  • 531
  • 4
  • 10
  • 1
    This is normal and expected. UNIX operating systems -- and MacOS is one -- do not expect CR characters to be present on the end of scripts, and will treat those characters as data. It's _always_ the case, not just after you "mess around with settings". – Charles Duffy Mar 25 '21 at 20:01
  • 1
    That said, I do wonder if you might have changed your git settings (if that's the tool you use to retrieve files from the "shared repository" in question). `git` _can_ automatically convert files to follow local conventions for you; that's an optional feature, and can be toggled on and off. – Charles Duffy Mar 25 '21 at 20:03
  • 1
    See git's `core.eol`, `core.autocrlf`, and `core.safecrlf` settings, as configured both globally and for your specific repository. If you're using a different source control system, ask a question _about that specific system_. – Charles Duffy Mar 25 '21 at 20:05
  • 1
    @Daven If you don't need the gnu version of things found first put the path stuff the other way round .. i.e. `export PATH="$PATH:/usr/local/opt/coreutils/libexec/gnubin"`. Similarly for the GEM path `export PATH="$PATH:$GEM_HOME/bin"` otherwise you might end up with surprises. If it's intentional - no problem. – Mr R Mar 25 '21 at 20:05
  • @CharlesDuffy @Mr R Thank you both your help! It turns out it was my git settings, whenever I checkout files. Using `git config --global core.autocrlf input` solved a lot of problems for me. – Daven Mar 26 '21 at 10:42

0 Answers0