3
我正在編寫調用劣質進程的模式。啓動過程中的一行是:Elisp:使用包含空格的路徑調用啓動進程
(setq grass-process (start-process "grass" "*grass*" "grass" "-text"
(concat (file-name-as-directory
(cdr grass-location))
grass-mapset)))
grass-location
和grass-mapset
是包含的路徑,根目錄兩個字符串,並以嵌套目錄中的一個,分別需要被級聯作爲參數set-process
。
當grass-location
和grass-mapset
包含沒有空格的正常目錄時,此方法正常工作。然而,當有目錄名稱的空間,它被傳遞給start-process
時,產生以下錯誤刪除:
grass-location
=> ("geobase Canada" . "/home/tws/grassdata/geobase Canada")
grass-mapset
=> "PERMANENT"
;; Calling start-process as above, the following error is produced
;; in the *grass* buffer:
Cleaning up temporary files ...
Starting GRASS ...
/home/tws/grassdata/geobaseCanada/PERMANENT: Not a valid GRASS location
Process grass exited abnormally with code 1
注意geobase Canada
減少到geobaseCanada
。我試過在concat
表達式中加入引號來保護這個字符串,但是它會產生更奇怪的錯誤,並且主目錄會被添加到參數中。
我該如何傳遞一個路徑名以及其中的空格來啓動進程?
您確定錯誤來自您的'start-process'表達式,而不是來自'grass '程序本身? (例如,第二個參數似乎與第一個參數連接在一起;在這個過程中可能會丟失空格......) – Francesco 2012-03-23 15:09:07
您說得對,我從xterm開始草的同樣的錯誤。謝謝! – Tyler 2012-03-23 15:30:57
@Francesco你可以讓這個答案真實,所以這個問題不會被過濾爲未答覆? – 2012-03-25 00:30:57