2

So I have been used for a very long time to typing special characters such as accented vowels and the quite common ñ in Spanish language when using bash on my Mac. Specifically, I used to write commit messages in Spanish via bash using these characters, no problem.

After upgrading my Mac to OS X El Capitan 10.11.5, I noticed that as soon as I type one of these characters, the prompt changes and does not display the typed character, for instance, pressing ñ changes my prompt from

host:directory username  $

to

(arg: 1)

instead of simply showing ñ on the screen. A similar thing happens with other accentuated characters and other special characters, except the index displayed next to arg changes.

While working on my MacBook Air with OSX Yosemite 10.10.5, these characters display without a problem on the command line, as I was used to.

Both computers have the same set of encodings set in Terminal>Preferences, so that shouldn't be the issue. Also, the output of locale on both computers is the same, namely

LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

I thought the terminal would be the only affected area through this update. It really turned into a problem when running a python script that would run perfectly on my OSX 10.10.5 Mac, would exit with encoding errors on my 10.11.5 Mac, under the SAME version of Python (3.4.3).

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
jvrsgsty
  • 588
  • 4
  • 18
  • I don't know Mac, but that `(arg: 1)` looks like your keystrokes have invoked a Bash [Readline argument](http://stackoverflow.com/a/562179/4014959) – PM 2Ring May 27 '16 at 18:55
  • In the Preferences > Profiles > Advanced tab, towards the bottom, there's a section 'International' and a drop-down box to the right of 'Text encoding'. Does that say 'Unicode (UTF-8)'? I'm unable to reproduce on a MacBook Pro (13") running El Capitan 10.11.5. I was able to type 'Option-n' and then 'n' to generate 'ñ' without problems, in both shell and Firefox when typing this comment. And the terminal generated bytes 0xC3 0xB1 which looks (at minimum) plausible. – Jonathan Leffler May 27 '16 at 19:21
  • @JonathanLeffler In fact, they were both set to UTF-8. The issue was with the 'Set locale variables on startup' checkbox, as you can see in my answer. Thanks for pointing me in the right direction. – jvrsgsty May 28 '16 at 17:59

1 Answers1

3

I finally got it sorted out. I compared my terminal profile settings on both my macs bit by bit. The only option in which they were different, was in fact under Preferences>Profiles>Advanced. The 'International' section has a checkbox for setting locale variables on startup. This was not checked on my non-working Mac, whereas it was checked on my working MacBook Air. Checking the box and restarting the Terminal did it for me. I am not quite sure what else is set on startup with this option, seeing locale variables were set to the same values on both computers even before I found the fix.

Everything now works like a charm, I can type special characters on my shell again but most importantly, my python scripts now run perfectly without any encoding issues.

jvrsgsty
  • 588
  • 4
  • 18