Как получить доступ к переменной окружения bash из R в emacs-ess
В моем .bashrc у меня есть строка:
export SETTINGS=/home/user/settings.xml
Если я загружаю R в Bash, я могу получить доступ к этой переменной с помощьюSys.getenv
функция:
Sys.getenv("SETTINGS")
"/home/user/settings.xml"
Если я открою R в Emacs (M-x R), SETTINGS будет пустым:
Sys.getenv("SETTINGS")
""
Что я пробовал:
adding the following to .emacs, based on How do I make Emacs recognize bash environment variables for compilation?
;; get environment vars from .bashrc
(let ((path (shell-command-to-string ". ~/.bashrc; echo -n $SETTINGS")))
(setenv "SETTINGS" path))
opening up bash in emacs using M-x term
echo $SETTINGS # works
R
Sys.getenv("SETTINGS") #works
If I open emacs from the terminal, the SETTINGS variable is available as expected. Opening emacs from the Applications menu (with either the command /usr/bin/emacs23 %F
or emacs
) does not work.
comparing output from session("env")
when loading R in bash vs emacs, but nothing stands out other than (bash = <, emacs = >):
> INSIDE_EMACS=23.3.1,comint
6d5
< SETTINGS=/home/user/settings.xml
9c8
< SHLVL=1
> SHLVL=0
14a14
> PAGER=cat
16d15
< PAGER=/usr/bin/pager
19d17
< COLORTERM=gnome-terminal
25c23
< WINDOWID=14680069
> DESKTOP_AUTOSTART_ID=1020ce948b944a88113395253627645060000001863000
< TERM=xterm
> TERM=dumb
Могу ли я либо
access SETTINGS from within R in emacs-ess export SETTINGS somewhere that I can access it?