[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quotes do not display correctly

From: Nick Helm
Subject: Re: Quotes do not display correctly
Date: Fri, 15 Apr 2016 04:05:12 +0000

> How are you setting LANG?  In a ~/.bashrc file?  I don't know anything
> about Apple OS X but in regular X11 settings in ~/.bashrc files only
> affect interactive shells and not other programs that are not
> interactive bash shells.  

I have LANG set in my ~/.bash_profile. As I understand it, OSX runs a new
login shell each for each instance, so I have never bothered
to create a ~/.bashrc file on Macs.

> In order to set the environment in X Windows for example one way would be in
> a .xsessionrc file which is specifically loaded by the window system. I
> would guess it is similar with other systems.

I think that's pretty much how it works on OSX too, as I understand it.
Although there seems to be several ways to do it, including setting variables
in /etc/launchd.conf (the global config file for OSX's service manager/process
launcher), or creating ~/Library/LaunchAgents/environment.plist, which seems
to be an XML script that launchd uses to configure the environment when
launching an app.

> That line break and indent seems unintentional.  Mailer problem?  I
> assume it was meant to be this.  Which I am going to comment upon.

Yes, a problem manually introduced by me. Sorry about that.

> I wanted to comment upon the way you set the variable.  That works,
> obviously.  But it isn't very idiomatic.  It is possible that the
> inclusion of a ';' shell metacharacter in the string will require a
> "/bin/sh -c" to be invoked in order to interpret the script.  Often
> programs optimize the /bin/sh call out if there are no shell
> meta-characters.  But the above requires it.
> Better would be to use the "env" command to run something in a
> modified environment.  It is one of the POSIX standard commands and
> very portably found on systems.  This avoids the need for shell
> meta-characters, may allow the system to optimize the shell out, and
> allows very fine control of the environment.  With that it would be:
>  env LANG=en_NZ.UTF-8 /Applications/ -Q --daemon

Thank you, this is good advice. At the time, I was convinced my script was at
fault, so I was attempting to use export as a way to force an environment
change within each "do shell script" to test what was going on. I didn't
know I could use env in this way.

> Having said all of the above I am not sure this is the best solution.
> This is simply the first environment variable you have set somewhere
> (~/.bashrc ?) and you may run into other problems.  It might be better
> to figure out how to get your environment set somewhere, such as in
> the X11 ~/.xsessionrc file case, rather than play the wack-a-mole game
> hitting individual environment variables one by one as you run into
> problems not having them.

I agree, this not ideal, so I removed the export commands in my script and
tweaked my ~/Library/LaunchAgents/environemt.plist to include the 
following (XML omitted):

   launchctl setenv LANG en_NZ.UTF-8 
   launchctl setenv TERM xterm-256color
   launchctl setenv HOME /Users/nick 
   launchctl setenv PATH 

This also fixes my quoting problem and I can interrogate LANG and the other
variables from within Emacs with `getenv' and get the values I expect. As a
bonus, it now looks like Emacs is getting the correct PATH, which, up until
now, I’ve had to fudge with this ancient tweak in my init.el:

   (setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH"))) 
   (setq exec-path (append '("/usr/local/bin") exec-path))

Which suggests I've played whack-a-mole before, so thanks for the prompt to
sort this out.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]