4

Is it possible to set the default-directory temporarily (e.g., let-bound) when using start-process? If so, how please.

(let ((default-directory "/Users/HOME/Desktop/tmp"))
  (start-process "touch-file" nil "touch" "test.txt"))

start-process ignores a let-bound default-directory.

6

default-directory has to be a directory, not the filename of a directory. In other words it has to end with a slash. In some places it does not matter whether a directory path ends with a slash or not, here it does.

(let ((default-directory "/some/directory/"))
  ...)
  • Works on linux without a slash – abo-abo Dec 25 '14 at 22:11
  • I'm on OSX, so in my case it made the difference -- i.e., expand-file-name is no longer needed. – lawlist Dec 25 '14 at 22:18
3

Just expand the file name:

(let ((default-directory "/Users/HOME/Desktop/tmp"))
  (start-process "touch-file" nil "touch"
                 (expand-file-name "test.txt")))
  • tarsius hit the nail on the head, so I had to move the checkmark -- sorry -- your help is always appreciated. A forward slash at the end of the default-directory eliminates the need for expand-file-name on an OSX machine. – lawlist Dec 25 '14 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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