Subject: Re: bug#67736: 30.0.50; emacsclient.desktop fails with quoting-related error

From: Ulrich Mueller <[email-masked]>
Date: Sun, 17 Dec 2023 16:35:19 +0100

>>>>> On Sun, 17 Dec 2023, Peter Oliver wrote:

> Mekeor Melire wrote:

>> $ xdg-open example.txt
>> egrep: warning: egrep is obsolescent; using grep -E
>> [: -c: line 1: unexpected EOF while looking for matching `"'
>> [: -c: line 2: syntax error: unexpected end of file
>> [: -c: line 1: unexpected EOF while looking for matching `"'
>> [: -c: line 2: syntax error: unexpected end of file
>> [: -c: line 1: unexpected EOF while looking for matching `"'
>> [: -c: line 2: syntax error: unexpected end of file
>> Does anyone else experience this problem?

> I don’t experience it on Fedora, but I notice that the Fedora version
> of xdg-utils carries an awful lot of patches
> (https://src.fedoraproject.org/rpms/xdg-utils/tree/f38).

I cannot reproduce the problem on Gentoo either. The Gentoo package uses
a snapshot of xdg-utils from 2021 because the 1.1.3 release is very old:
https://gitlab.freedesktop.org/xdg/xdg-utils/-/commits/1a58bc28f6844898532daf9ee1bf6da7764955a9/

(Also, xdg-utils-1.2.0 seems to be on its way; upstream has released a
1.2.0-beta1 version.)

> I agree that the quoting is too complex, and would be better
> eliminated.

I've double checked: The quoting in the desktop file is definitely
according to the specification. IMHO it isn't particularly complex in
emacsclient.desktop, at least compared to what we previously had in
emacsclient-mail.desktop.

> A wrapper script could achieve the same functionality.

All previous committers have avoided a wrapper script, because inlining
the shell command gets the work done.

Plus, wouldn't it be better to integrate the functionality of any
wrapper script in the emacsclient binary directly?

[Restoring some of the quoted context]

>>     Commit: d32091199ae5de590a83f1542a01d75fba000467
>>     Author: Ulrich Müller <[email-masked]>
>>     Date:   Mon Dec 19 16:51:20 2022 +0100
>>     Message:
>>         Use `sh` rather than `placeholder` as the command name of the
>>         shell wrapper. (Bug#60204)
>>     Code:
>>         Exec=sh -c "if [ -n \\"\\$*\\" ]; then exec emacsclient
>>         --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\";
>>         else exec emacsclient --alternate-editor= --create-frame; fi"
>>         sh %F

This commit didn't do anything significant for emacsclient.desktop, it
only changed the command name (which is shown e.g. in "ps" output) from
"placeholder" to "sh".