Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / 6d / 1d45e339449323f9ab6a147cad501405956385
1 Return-Path: <amdragon@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id AEAB840DEED\r
6         for <notmuch@notmuchmail.org>; Thu, 18 Nov 2010 17:30:27 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.998\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.998 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
13         DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001,\r
14         RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id MQUhPJOyoF1X for <notmuch@notmuchmail.org>;\r
18         Thu, 18 Nov 2010 17:30:17 -0800 (PST)\r
19 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com\r
20         [209.85.216.181])\r
21         by olra.theworths.org (Postfix) with ESMTP id 35D1240DEEA\r
22         for <notmuch@notmuchmail.org>; Thu, 18 Nov 2010 17:30:17 -0800 (PST)\r
23 Received: by qyk1 with SMTP id 1so33877qyk.5\r
24         for <notmuch@notmuchmail.org>; Thu, 18 Nov 2010 17:30:14 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=domainkey-signature:mime-version:received:received:in-reply-to\r
27         :references:date:message-id:subject:from:to:cc:content-type;\r
28         bh=Nqz1zmDMrt5of3wbT4KXCKbkXPLHIuwXve3MPL1i5KQ=;\r
29         b=jHwiSEyT701ga8WcGhhywUBZ3Feu6zQSU+a+cCBCdBnztnN7ooIZ86BlW7kY6BymBj\r
30         sat8wPVnKE4nKAwd2bppgI2n1dHodSsIjEHB9YGzxTylXMKYKdH8LgerG0xW51IWxjxp\r
31         xApQWQvfOhmsNklLsF3UwEyMXbbDlDLfwLQwg=\r
32 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
33         h=mime-version:in-reply-to:references:date:message-id:subject:from:to\r
34         :cc:content-type;\r
35         b=FE9x0rAxoiaLo0YVg7JNp+jtb6735OuiReGGfNX04nmVLzjAEqMcnN1buaFzbdutxC\r
36         ev0vIQuiQNL87g8uJZFqsj6XbjPHzLYaob2dyAVNbFT7+L+s7nCHZKv0lgH9Nq1CDSwO\r
37         lNamZVqSJQfX96sye5xx5XraQ5+HNCrhNvSDc=\r
38 MIME-Version: 1.0\r
39 Received: by 10.229.91.211 with SMTP id o19mr1262887qcm.87.1290130214231; Thu,\r
40         18 Nov 2010 17:30:14 -0800 (PST)\r
41 Received: by 10.229.224.202 with HTTP; Thu, 18 Nov 2010 17:30:14 -0800 (PST)\r
42 In-Reply-To: <87wroa49w4.fsf@wsheee.2x.cz>\r
43 References: <AANLkTin_2gWHg2omVdRwDbm8-m3FoJn6cvVakMRBnNEZ@mail.gmail.com>\r
44         <87wroa49w4.fsf@wsheee.2x.cz>\r
45 Date: Thu, 18 Nov 2010 20:30:14 -0500\r
46 Message-ID: <AANLkTinUdSygCmRYKbZyq4xH-FZfYRh7_4VPUq_gbYS3@mail.gmail.com>\r
47 Subject: Re: Bug in remote use of notmuch\r
48 From: Austin Clements <amdragon@gmail.com>\r
49 To: Michal Sojka <sojkam1@fel.cvut.cz>\r
50 Content-Type: multipart/alternative; boundary=001636310389221fb604955dd975\r
51 Cc: notmuch@notmuchmail.org\r
52 X-BeenThere: notmuch@notmuchmail.org\r
53 X-Mailman-Version: 2.1.13\r
54 Precedence: list\r
55 List-Id: "Use and development of the notmuch mail system."\r
56         <notmuch.notmuchmail.org>\r
57 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
59 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
60 List-Post: <mailto:notmuch@notmuchmail.org>\r
61 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
62 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
64 X-List-Received-Date: Fri, 19 Nov 2010 01:30:27 -0000\r
65 \r
66 --001636310389221fb604955dd975\r
67 Content-Type: text/plain; charset=ISO-8859-1\r
68 \r
69 Unfortunately, expansion *is* performed by the remote shell, which is why\r
70 your shell quoting approach works (and is necessary).  There's really no way\r
71 around this, since the ssh client simply joins all of its trailing arguments\r
72 with spaces and sends this single string to the ssh server, which exec()s\r
73 $SHELL -c <string>.\r
74 On Nov 18, 2010 4:09 PM, "Michal Sojka" <sojkam1@fel.cvut.cz> wrote:\r
75 > On Wed, 10 Nov 2010, Mark Walters wrote:\r
76 >> I am experimenting with using notmuch remotely over ssh (as in the\r
77 >> NEWS file; i.e. with a script containing ssh user@host notmuch "$@")\r
78 >> This is mostly excellent but it seems to get confused by some queries.\r
79 >> For example those containing brackets or just consisting of *. I think\r
80 >> this is a problem with ssh spawning a shell on the remote machine\r
81 >> which doesn't like the brackets or *.\r
82 >>\r
83 >> Explicitly to reproduce the problem start notmuch with a remote\r
84 >> database using a script as above;\r
85 >> type * in the search box;\r
86 >> and emacs shows:\r
87 >> End of search results. (process returned 1)\r
88 >\r
89 > Hi Mark,\r
90 >\r
91 > you are right, that there are problems with the queries containing shell\r
92 > meta characters. AFAIK the probelm is not caused by the remote shell, as\r
93 > notmuch is there invoked directly by ssh, but by the shell invoking the\r
94 > ssh. I do not know precisely why, but the following script seems to work\r
95 > correctly even for the queries containing shell meta characters. It uses\r
96 > bash's printf extension to print shell-quoted version of a string.\r
97 >\r
98 > #!/bin/bash\r
99 > printf -v args "%q " "$@"\r
100 > ssh example.org notmuch $args\r
101 >\r
102 > -Michal\r
103 > _______________________________________________\r
104 > notmuch mailing list\r
105 > notmuch@notmuchmail.org\r
106 > http://notmuchmail.org/mailman/listinfo/notmuch\r
107 \r
108 --001636310389221fb604955dd975\r
109 Content-Type: text/html; charset=ISO-8859-1\r
110 Content-Transfer-Encoding: quoted-printable\r
111 \r
112 <p>Unfortunately, expansion *is* performed by the remote shell, which is wh=\r
113 y your shell quoting approach works (and is necessary). =A0There&#39;s real=\r
114 ly no way around this, since the ssh client simply joins all of its trailin=\r
115 g arguments with spaces and sends this single string to the ssh server, whi=\r
116 ch exec()s $SHELL -c &lt;string&gt;.</p>\r
117 \r
118 \r
119 <div class=3D"gmail_quote">On Nov 18, 2010 4:09 PM, &quot;Michal Sojka&quot=\r
120 ; &lt;<a href=3D"mailto:sojkam1@fel.cvut.cz" target=3D"_blank">sojkam1@fel.=\r
121 cvut.cz</a>&gt; wrote:<br type=3D"attribution">&gt; On Wed, 10 Nov 2010, Ma=\r
122 rk Walters wrote:<br>\r
123 \r
124 &gt;&gt; I am experimenting with using notmuch remotely over ssh (as in the=\r
125 <br>&gt;&gt; NEWS file; i.e. with a script containing ssh user@host notmuch=\r
126  &quot;$@&quot;)<br>&gt;&gt; This is mostly excellent but it seems to get c=\r
127 onfused by some queries.<br>\r
128 \r
129 &gt;&gt; For example those containing brackets or just consisting of *. I t=\r
130 hink<br>&gt;&gt; this is a problem with ssh spawning a shell on the remote =\r
131 machine<br>&gt;&gt; which doesn&#39;t like the brackets or *.<br>&gt;&gt; <=\r
132 br>\r
133 \r
134 &gt;&gt; Explicitly to reproduce the problem start notmuch with a remote<br=\r
135 >&gt;&gt; database using a script as above;<br>&gt;&gt; type * in the searc=\r
136 h box;<br>&gt;&gt; and emacs shows:<br>&gt;&gt; End of search results. (pro=\r
137 cess returned 1)<br>\r
138 \r
139 &gt; <br>&gt; Hi Mark,<br>&gt; <br>&gt; you are right, that there are probl=\r
140 ems with the queries containing shell<br>&gt; meta characters. AFAIK the pr=\r
141 obelm is not caused by the remote shell, as<br>&gt;  notmuch is there invok=\r
142 ed directly by ssh, but by the shell invoking the<br>\r
143 \r
144 &gt; ssh. I do not know precisely why, but the following script seems to wo=\r
145 rk<br>&gt; correctly even for the queries containing shell meta characters.=\r
146  It uses<br>&gt; bash&#39;s printf extension to print shell-quoted version =\r
147 of a string.<br>\r
148 \r
149 &gt; <br>&gt;   #!/bin/bash<br>&gt;   printf -v args &quot;%q &quot; &quot;=\r
150 $@&quot;<br>&gt;   ssh <a href=3D"http://example.org" target=3D"_blank">exa=\r
151 mple.org</a> notmuch $args<br>&gt; <br>&gt; -Michal<br>&gt; _______________=\r
152 ________________________________<br>\r
153 \r
154 &gt; notmuch mailing list<br>&gt; <a href=3D"mailto:notmuch@notmuchmail.org=\r
155 " target=3D"_blank">notmuch@notmuchmail.org</a><br>&gt; <a href=3D"http://n=\r
156 otmuchmail.org/mailman/listinfo/notmuch" target=3D"_blank">http://notmuchma=\r
157 il.org/mailman/listinfo/notmuch</a><br>\r
158 \r
159 </div>\r
160 \r
161 --001636310389221fb604955dd975--\r