joaotavora / sly

Sylvester the Cat's Common Lisp IDE
1.26k stars 142 forks source link

Setting `sly-lisp-implementations` to a command that has quotes #632

Closed aadcg closed 6 months ago

aadcg commented 6 months ago

The following commands are valid ways to start lisp:

However:

C-u M-x sly RET nix-shell -p sbcl --run "sbcl --dynamic-space-size 3072" => OK C-u M-x sly RET nix-shell -p sbcl --run 'sbcl --dynamic-space-size 3072' => error: unrecognised flag '--dynamic-space-size'

If these are elements of sly-lisp-implementations:

M--- M-x sly RET test1 => /tmp/nix-shell-9574-0/rc: line 3: sbcl --dynamic-space-size 3072: command not found M--- M-x sly RET test2 => /tmp/nix-shell-10951-0/rc: line 3: sbcl --dynamic-space-size 3072: command not found


At the heart of these bugs lies:

(start-process "test" (get-buffer-create "test") "nix-shell" "-p" "sbcl" "--run" "'sbcl --dynamic-space-size 3072'")
=> (opens a buffer called test):
/tmp/nix-shell-13722-0/rc: line 3: sbcl --dynamic-space-size 3072: command not found

Process test<1> exited abnormally with code 127

I wonder if there's a way for start-process to handle the quotes.

aadcg commented 6 months ago

Regarding sly-list-implementation, I've noticed that adding the element (test ("nix-shell" "-p" "sbcl" "--run" "sbcl --dynamic-space-size 2345")) does work which, in retrospective, makes sense.

It is still a mystery why C-u M-x sly RET nix-shell -p sbcl --run 'sbcl --dynamic-space-size 3072' doesn't work, but I can live with that.

joaotavora commented 6 months ago

It is still a mystery why C-u M-x sly RET nix-shell -p sbcl --run 'sbcl --dynamic-space-size 3072' doesn't work, but I can live with that.

You could edebug it and see what eventually makes it to the make-process C function...

There's some (not idea exactly how much) magic in Eglot, another extension that executes extgernal processes, to handle that. I'm fairly sure I cargo culted from somewhere. Maybe split-string-and-unquote? Maybe it can be retrofitted in SLY? But is it the same use case? Also I think that helper only understands double quotes, not single.

monnier commented 6 months ago

There's some (not idea exactly how much) magic in Eglot, another extension that executes extgernal processes, to handle that. I'm fairly sure I cargo culted from somewhere. Maybe split-string-and-unquote? Maybe it can be retrofitted in SLY? But is it the same use case? Also I think that helper only understands double quotes, not single.

[ Sorry, I haven't really tried to understand the more global context of the question/problem, so just a "drive-by shooting": ]

split-string-and-unquote does not try to handle the usual Bourne shell syntax. Instead it uses the ELisp syntax of strings, so indeed it only accepts double-quotes and is thus not appropriate if the intention is to try and mimic sh-style parsing.

joaotavora commented 6 months ago

You're 100% percent right Stefan, probably not a good idea at all. The only way to get perfect shell-quoting behaviour is just making processes via the shell, and I find it's not needed often.