From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#65902: 29.0.92; emacsclient-mail.desktop fails due to complicated escaping Date: Thu, 14 Sep 2023 17:31:28 +0300 Message-ID: <83o7i4ltbz.fsf@gnu.org> References: <83ttrym8jx.fsf@gnu.org> <83led9nay9.fsf@gnu.org> <66a6c09e-3b61-d913-5638-4c804fb826f6@gmail.com> <83edj1mja5.fsf@gnu.org> <87il8dt3sh.fsf@catern.com> <83pm2klvw9.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29976"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65902@debbugs.gnu.org, sbaugh@catern.com, jporterbugs@gmail.com To: Spencer Baugh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 14 16:32:24 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qgnOI-0007YX-HS for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Sep 2023 16:32:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgnNu-0006pV-CQ; Thu, 14 Sep 2023 10:31:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgnNs-0006pM-SH for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 10:31:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgnNs-0007V5-IO for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 10:31:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgnNy-0002F8-Cd for bug-gnu-emacs@gnu.org; Thu, 14 Sep 2023 10:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Sep 2023 14:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65902-submit@debbugs.gnu.org id=B65902.16947019178611 (code B ref 65902); Thu, 14 Sep 2023 14:32:02 +0000 Original-Received: (at 65902) by debbugs.gnu.org; 14 Sep 2023 14:31:57 +0000 Original-Received: from localhost ([127.0.0.1]:40763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgnNs-0002Ep-J2 for submit@debbugs.gnu.org; Thu, 14 Sep 2023 10:31:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47314) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgnNr-0002Ec-2V for 65902@debbugs.gnu.org; Thu, 14 Sep 2023 10:31:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgnNf-0007UI-5o; Thu, 14 Sep 2023 10:31:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=8wOmVQfDiz5idwfBZgJ8AnZOuMBBZUq5xKd+iPNFJ6E=; b=juMt/HHuXlpN jlAytLpntPrVv8FZVFuZr+xhD5xqPMoQqbqs5gIrhguJVL4uhx4bLgfIRRXX8JVewOvDiJF/hut29 HEdD6rPiiWHdTyZwktxDxP0zLBhB3whL1GFsT6S6n6Qk72GgudiuOfNIfTZ98j/aiAHzoEuas465M X7Xbvbne4fLR002mvlA9n4ON0hLLhCF9CfKOTpTOtcsgoe64vWcxc0mytGb9OhZ+HFZ0pDuk2wj44 2kNyOs06xCYgb0G0n9WoL7/GTvQU5+iilEq4cB3FVQb0Qlqb/VfyXtd7xaJraxVl+NwE2dgv0Dat3 8DBztjrkOvvkam6LC0VA9A==; In-Reply-To: (message from Spencer Baugh on Thu, 14 Sep 2023 10:04:48 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270438 Archived-At: > From: Spencer Baugh > Cc: sbaugh@catern.com, jporterbugs@gmail.com, 65902@debbugs.gnu.org > Date: Thu, 14 Sep 2023 10:04:48 -0400 > > Eli Zaretskii writes: > > > What you are doing is representing a rare problem related to a niche > > feature is if it were a general one, by inventing use cases to justify > > that. But if those use cases were important, people would have asked > > for them long ago. They didn't. Why? because --eval already exists. > > No... these are real use cases that I personally have. I have really > wanted this for a long time. As I said in my original email, "I expect > this to also be useful in other places; the need to escape arbitrary > inputs before passing them to emacsclient is frequently annoying." Maybe it's annoying, but it can be done. And Emacs has the same feature, btw. > > Emacs developers make mistakes even in the simple regexps we have in > > our code. That doesn't mean we should abandon regexps. The solution > > for sending Lisp forms to the server exists, and the quoting, although > > tricky in some cases, is not rocket science to get right. > > I think this (the current contents of emacsclient-mail.desktop): > sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec > emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval > \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u > > is in fact rocket science, and rocket science that needs to be repeated > by every user who wants to pass arbitrary strings to Emacs. We disagree. > And keep in mind this mass of escaping *is currently broken*. Patches to fix it are welcome, although as I said I'd be quite glad to remove these desktop files from our repository. > > That's an illusion. There's nothing simple about it. You are > > inventing a new mechanism for passing Lisp forms as something other > > than Lisp. > > But I don't want to pass Lisp forms, that's the entire point. I have > some arbitrary string which is *not* Lisp, and I want Emacs to *not* > parse it as Lisp. It becomes Lisp when the server executes the request. > > $ emacsclient --apply func arg1 'foo arg2 'bar > > > > Escape-quoting, here we come again! > > That example works fine with --apply. The call becomes: > (func "arg1" "'foo" "arg2" "'bar") > which is reliable and expected. > > Maybe you're referring to how, if you run that command through a shell, > the shell interprets the single quotes as creating a string? Of course, I am! > But that's that's a separate issue, because: > > - I don't plan to run any of my commands using --apply through a shell > (which means they will require zero escaping or quoting whatsoever) This feature, if it will be added, is not just for you, it's for everyone. And emacsclient is a shell command, so invoking it from the shell is both natural and frequently used. > - Right now with --eval you have to do escaping for both the shell and > Lisp. With --apply you only have to do escaping for the shell, if you > do use a shell, and if you don't use a shell you don't have to do > anything. But we do that for Emacs, and do it quite a lot. > I think it is simpler to reduce the amount of quoting and escaping from > "both Lisp and shell" to "just shell, and not even that if you don't use > a shell". At what cost? The cost of adding yet another protocol for passing Lisp forms to the server is just too high for my palate. Bottom line: the escaping issue doesn't seem to me a reason strong enough to justify adding such a new feature.