[OS X TeX] Staying on the right PATH (or something)
morten.hoegholm at gmail.com
Thu Nov 15 09:29:24 CET 2007
On Wed, 14 Nov 2007 17:19:47 +0100, Charilaos Skiadas wrote:
Hi Charilaos and others,
Thanks for all the answers - it seems like you all agree so I'll do what
I'd do on Who Wants to be a Millionaire and follow the group. :-)
> I'm sure other people will give much more enlightening answers, but the
> gist of it is that GUI applications don't get to call the shell
> initialization scripts that get run when a terminal opens. So anything
> that is defined in files like .bash_profile, .tchrc doesn't get read
> when in a GUI.
OK this makes sense. This is also what Peter wrote.
> For instance if you open TeXShop/Texmaker or whatnot from the terminal
> using "open", then it will inherit the environment from the terminal and
> hence will have the things defined.
Aha. Yes, that does indeed work.
> But if you open the app from finder by double-clicking, then the process
> calling it is not the terminal, hence it will not have these variables
OK, I got it now.
I think it is best (and easiest) if one does not have to know the full
path to the executable. Granted, it is much better on OS X now with
/usr/texbin but it still requires specifying the path rather than just the
name of the executable. When doing support for this large group of people,
we would like to ease our own task and just make it work with the
Now knowing roughly what to look for, I dug into the Aquamacs Emacs
sources and found that it during startup runs the function
(defun mac-read-environment-vars-from-shell ()
"Import the environment from the system's default login shell
specified in `shell-file-name'."
;; execute 'printenv' with the default login shell,
;; running the shell with -l (to load the environment)
(setq default-directory "~/") ; ensure it can be executed
;; To Do: use call-process instead -> this here
;; will invoke two bashes
(if (string-match ".*/\\(ba\\|z\\)sh" shell-file-name)
(if (string-match ".*/\\tcsh" shell-file-name)
(if (string-match ".*/ksh" shell-file-name)
"" ;; works for ksh
(message "Could not retrieve login shell environment with login
shell: %s" shell-file-name)
;; won't work for csh, because it doesn't take -l -c ...
(call-process shell-file-name nil
(while (re-search-forward "^[A-Za-z_0-9]+=()\s*[^\x]*?
\s*}\s*$" nil t)
(replace-match "..." nil nil))
(while (search-forward-regexp "^\\([A-Za-z_0-9]+\\)=\\(.*\\)$" nil t)
(if (equal (match-string 1) "PATH")
(concat (match-string 2) ":" (getenv "PATH"))
I'll see if we can use this somehow.
More information about the macostex-archives