Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am new to Elisp. I would like to do the following in my init file:

; Retrieve the value of LD_LIBRARY_PATH
; Append '/path/to/some/lib/:'to it
; Save the new value of LD_LIBRARY_PATH

So far I know that I can use:

(getenv "LD_LIBRARY_PATH")

to retrieve the value, and:

(setenv "LD_LIBRARY_PATH" "foo")

to set a new value, but my knowledge of Elisp is extremely rudimentary so I don't know to proceed from this point.

Background:

This question is inspired by the fact that it is not be possible to source a shell script to manipulate this environment from within Emacs, so I would need to do this using Elisp.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

In Elisp, string concatenation is done with concat:

(setenv "LD_LIBRARY_PATH"
  (let ((current (getenv "LD_LIBRARY_PATH"))
        (new "/path/to/some/lib"))
    (if current (concat new ":" current) new)))
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.