alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
278 stars 49 forks source link

Command lines containing spaces inside arguments not supported in editor.cmd #1314

Open mgrojo opened 1 year ago

mgrojo commented 1 year ago

Related to #1313

As commented in the emacs ada-mode users list:

Thanks. Now, I am able to set it in this way:

alr config --set --global editor.cmd 'emacs --eval=(ada-build-prompt-select-prj-file"${GPR_FILE}") ${GPR_FILE}'

Note that there is no space between the function and the string argument. Otherwise, Alire splits the argument and Emacs is not able to evaluate it correctly. Don't know if that could be considered a bug in Alire or not, but I couldn't find a proper way to escape the space.

The space problem sounds like a bug, but it could be in your shell rather than in Alire. It's simpler just to edit the alire config file directly; it's ~/.config/alire/config.toml

When the config file is edited and space added:

$ alr edit
Editing crate with: ['emacs' '--eval=(ada-build-prompt-select-prj-file', '"play_2048.gpr")', 'play_2048.gpr']

And then Emacs errors:

command-line-1: End of file during parsing

That can be attributed to Alire, it's splitting the command assuming spaces as separator, so command lines containing spaces inside arguments are not supported. Using shell syntax (e.g. single quotes) inside the config file doesn't work either.

It's a very limited need and maybe difficult to solve it portably, but I think it deserves its own issue.

mgrojo commented 1 year ago

This is where the command line is split: https://github.com/alire-project/alire/blob/49c04043a3a8d259257729191f5bfe4a104385e5/src/alr/alr-commands-edit.adb#L67

I guess fixing it is not easy and would imply user-visible changes, but the workaround of joining function and string luckily worked.

mosteo commented 1 year ago

Thanks, @mgrojo, certainly worth to keep tabs on this but, as you say, not trivial unless we locate some lib with ready-to-use cleverer splitting of strings.