From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel Newsgroups: gmane.emacs.bugs Subject: bug#25025: python-shell-calculate-command is wrong Date: Fri, 2 Dec 2016 11:15:16 -0500 Message-ID: References: <83polk3qow.fsf@gnu.org> <83inra13r3.fsf@gnu.org> <8337ic29y0.fsf@gnu.org> <87r35wj4b8.fsf@users.sourceforge.net> <83zikkzytf.fsf@gnu.org> <8737i9iz28.fsf@users.sourceforge.net> <1949fc46-fd26-dddb-86b2-ab3478587271@gmail.com> <87wpflhgsf.fsf@users.sourceforge.net> <83a8chq7x6.fsf@gnu.org> <83d1hbpobp.fsf@gnu.org> <87h96ngmmq.fsf@users.sourceforge.net> <83k2biokad.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lrBC0wutRvkgK0g4RsCkUPMQSgTl6osf8" X-Trace: blaine.gmane.org 1480695384 9947 195.159.176.226 (2 Dec 2016 16:16:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 2 Dec 2016 16:16:24 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 Cc: 25025@debbugs.gnu.org To: Eli Zaretskii , npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 02 17:16:20 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCqVV-0001XW-6x for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Dec 2016 17:16:17 +0100 Original-Received: from localhost ([::1]:35378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCqVZ-0007G6-22 for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Dec 2016 11:16:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCqVL-0007E1-IA for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 11:16:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCqVG-0003HP-Ij for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 11:16:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35112) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cCqVG-0003HG-Fh for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 11:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cCqVG-0000qi-7n for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 11:16:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2016 16:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25025 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 25025-submit@debbugs.gnu.org id=B25025.14806953463241 (code B ref 25025); Fri, 02 Dec 2016 16:16:02 +0000 Original-Received: (at 25025) by debbugs.gnu.org; 2 Dec 2016 16:15:46 +0000 Original-Received: from localhost ([127.0.0.1]:50511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCqUz-0000qD-PS for submit@debbugs.gnu.org; Fri, 02 Dec 2016 11:15:45 -0500 Original-Received: from mout.kundenserver.de ([212.227.17.13]:63669) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCqUy-0000py-71 for 25025@debbugs.gnu.org; Fri, 02 Dec 2016 11:15:44 -0500 Original-Received: from [18.189.73.191] ([18.189.73.191]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.184]) with ESMTPSA (Nemesis) id 0MDgeU-1cTtf03guU-00H5Fk; Fri, 02 Dec 2016 17:15:25 +0100 In-Reply-To: <83k2biokad.fsf@gnu.org> X-Provags-ID: V03:K0:UB2ZZ2j/fcKf1mpnMTCGXuOSpwiBW8JH//GNbO6FfUWo8MAxrc9 /k5DBU4E2ssXv1OAJmyh14P5D7YN2uxShceW8Epg3gexlxO04q0JKpCWxmvcDmGwt61JOYH Q33snLmBYAVzYMBzECQ8gcILnnCLqdLFWL43BVs9wy8npKGXAA1LlgF04B8ufBsltTuiHLo N5PlYKXCyMCCHs9m3vz5Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:RRASbh11KNo=:DgiCYRtQI8A3ukh758LGQp LYPauhVe6M2HnfGT448ocSYJ7YutJf8Zy1JJ6dC4/blYUnvNX7D+HKA9pq0g8GcvwDEZAdJMH OJgbauLO9GQ+lkoP//RfeXMQrqbHHAU4Quqe2uiYEX/ZUor2HczkbbsI95R7veAk/jQjW6rPL vLVEjPVCPY+cyYV9Z7udc329yV1jMdX4f9UkFsW0bNX42rb4ABYaSc+2k7qx809ksThC2K1U3 UBIwj3zPACuv7+6OsUBPXpURHkL5+Cy4nx2U3OBqu9LnTfhTEcH2oDnQjk0DvFb57km9Z7Mm6 nP2sy48+/+dRqOSk6HsTipskR5ns/5JeFPl1DrQwdeiuhZQ/LrMmsonHD8j954xrgOYfXqhZG Mxjk18pxb0kOWHyXqYrwNxW+Kj5rBmE46+jPGKwJcX0pQKeYxhgbAkynqHLtfmK7pWSIwsCoR o4lFx6Ks8PmQ6zvREo+S0A6ElSUB/IwBZtn353YLIZThEBFkY1NE2cXFiYw2z2BVuidoMnaRV x3Svpv41ELK5ZrAUB2asKaL0RodFzjcxYBgAGmx+RSpgz09szLAZ4OL7soKNWUv6nRXAdjohT RxFatA/vN6q0JDcY7YiVxrz69l17gaavRi0jSmhq7CAcpq2yH2AlW1E3wBVSf+NlTr31GGbVu F3hbi2CicSRIsogjIgSxhDIzwDTa3pS3D4Gi2/4I5H/ydC/W/1+3H5BbJlUpKdsRYA1s= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:126423 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --lrBC0wutRvkgK0g4RsCkUPMQSgTl6osf8 Content-Type: multipart/mixed; boundary="fV2Ohj7sWupFHDXvLdnfMo0lsfKEQcIUC"; protected-headers="v1" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: Eli Zaretskii , npostavs@users.sourceforge.net Cc: 25025@debbugs.gnu.org Message-ID: Subject: Re: bug#25025: python-shell-calculate-command is wrong References: <83polk3qow.fsf@gnu.org> <83inra13r3.fsf@gnu.org> <8337ic29y0.fsf@gnu.org> <87r35wj4b8.fsf@users.sourceforge.net> <83zikkzytf.fsf@gnu.org> <8737i9iz28.fsf@users.sourceforge.net> <1949fc46-fd26-dddb-86b2-ab3478587271@gmail.com> <87wpflhgsf.fsf@users.sourceforge.net> <83a8chq7x6.fsf@gnu.org> <83d1hbpobp.fsf@gnu.org> <87h96ngmmq.fsf@users.sourceforge.net> <83k2biokad.fsf@gnu.org> In-Reply-To: <83k2biokad.fsf@gnu.org> --fV2Ohj7sWupFHDXvLdnfMo0lsfKEQcIUC Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2016-12-02 02:35, Eli Zaretskii wrote: > Isn't combine-and-quote-strings wrong for quoting shell commands? > AFAIR, it doesn't DTRT with some special characters that can appear in > file names on Unix. Am I mistaken? >=20 > But if my fears are unjustified, sure, why not? Cl=E9ment, WDYT? On 2016-12-02 10:07, npostavs@users.sourceforge.net wrote: > Okay, let me rephrase. `python-shell-calculate-command' currently > generates a shell command, but none of its callers treat the result as = a > shell command (they don't pass it to a shell, they parse it with > `split-string-and-unquote'). Therefore, the easiest fix is to change > `python-shell-calculate-command' to no longer generate a shell command.= >=20 > The other possiblity is to change the callers to treat > `python-shell-calculate-command's result as a shell command, but that > looks more difficult (though it may be the better solution overall). Currently, run-python can read a shell command; do we want to remove this= feature? If not, then we do need a shell, don't we? As far as I understand we have two conflicting requirements: * One part of the code wants access to switches passed to python, as a li= st of switches. * One part of the code wants to read a python command, including switches= , from the user. I'm not sure that we can get these two to both work in all cases, unless = we come up with a robust way to parse shell commands given by the user. = I see multiple solutions: 1. Use a shell to run python. Then the part of the code that wants to kno= w which switches are being passed can use the possibly-incorrect split-st= ring-and-unquote to split user-supplied strings, but the user-supplied co= mmand is run as-is through a shell. 2. Keep running python as a subprocess, without a shell; in that case, us= er-supplied commands (in C-u M-x run-python) need to be "parsed" back int= o command + switches before running them, which introduces a small potent= ial for incorrect parsing. Noam, your approach is (2), right? I like the simplicity. In the long run, it would be nice to offer a read-shell-command-as-list f= unction, probably based on eshell. Cheers, Cl=E9ment. --fV2Ohj7sWupFHDXvLdnfMo0lsfKEQcIUC-- --lrBC0wutRvkgK0g4RsCkUPMQSgTl6osf8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYQZ4ZAAoJEPqg+cTm90wjr00P/1uYM80YKP7BWQuf/mpaJl/s N/rjcA9V5CCAxSOPEZ6kJIkImF4Rv7OHTZSGqo/Qr0pIsEA24UadxdK/LwyMtHdb BWLSGyyVfviN9ha4/cUqGx0tKrNeJ7uD8JLyDxKi7mr1uJ3FXzFbi0WBnMZDWLwB ALCjEXfHowVseMqxWjGrsXAjRhNMcZ0HXDpXsnSzhZ+8WDibD0dDxJFvCSiH1Z4K fyDNbt5g1YQ3OdC/+4KyEr0eLClfyf1WYrIaSXsMLnCEKPaJdT/nH9yYjOShIQaK oBZG+R2bwxB2vEPlCaOwEP2v4rwg6KZRsS90GWCIYVXFwdvKJErJZ/k4cpUOQx3F y3PL4P/3j+jMEZkB6MWzUpyIvhcLzaca6Eeks2eyMsXZWxssXVqyfblt9VuLv80L 6CIW8mUSK7ukQj+TFAV+Q2MqugVhQbp62rFEdypBn6OT6GRYy1SzJQY+5ywwJuQD dtWgFvxRR6O4X5ofUDAuBTvPk9oS0O6m/7RTxVJNU+vJjXWv90ehcggLKup/9tVK Wv1GHtdzfKmAKbcWRe2l50jxUECby3PQ/eNEZChS9x1DZJyH4YEwn1vDXGbpi9/P Jvch4PnVNwMIaFGUSVs1BM/WGPqdyE275IP42PPEbjlN+SNApa5dVGSiT/wfTPBR tS9oLfPC+q6C8lGt0y74 =ctjT -----END PGP SIGNATURE----- --lrBC0wutRvkgK0g4RsCkUPMQSgTl6osf8--