How to execute a shell command (e.g. git gui) from a specific directory? I would prefer a cross-platform approach that does not depend on shell operators such as &&or ;because I need it to work on Windows and unix. (For example, a call cd /path/to/dir && git guiwill not work on Windows because it is &&invalid.)
I tried:
(async-shell-command (concat "cd \""
(replace-regexp-in-string
"/" "\\\\" (file-name-directory (buffer-file-name))) "\" ; git gui"))
This crashes because for some reason the shell thinks it ; git guiis part of the path and it reports:The system cannot find the path specified.
So, I would prefer not to deal with shells, and I hope that there will be an elisp function that sets the directory for shell-commandor async-shell-command. I tried:
(shell-process-pushd (file-name-directory (buffer-file-name)))
(shell-command "git gui")
(shell-process-popd nil)
: git gui . ( , shell-process-pushd/popd .)
:
(start-process "gitgui" nil "git" "gui")
:
(let '(bufdir (file-name-directory (buffer-file-name)))
(with-temp-buffer
(print bufdir)
(cd bufdir)
(shell-command "git gui")))