Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id AEAB840DEED for ; Thu, 18 Nov 2010 17:30:27 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.998 X-Spam-Level: X-Spam-Status: No, score=-1.998 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MQUhPJOyoF1X for ; Thu, 18 Nov 2010 17:30:17 -0800 (PST) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) by olra.theworths.org (Postfix) with ESMTP id 35D1240DEEA for ; Thu, 18 Nov 2010 17:30:17 -0800 (PST) Received: by qyk1 with SMTP id 1so33877qyk.5 for ; Thu, 18 Nov 2010 17:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=Nqz1zmDMrt5of3wbT4KXCKbkXPLHIuwXve3MPL1i5KQ=; b=jHwiSEyT701ga8WcGhhywUBZ3Feu6zQSU+a+cCBCdBnztnN7ooIZ86BlW7kY6BymBj sat8wPVnKE4nKAwd2bppgI2n1dHodSsIjEHB9YGzxTylXMKYKdH8LgerG0xW51IWxjxp xApQWQvfOhmsNklLsF3UwEyMXbbDlDLfwLQwg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=FE9x0rAxoiaLo0YVg7JNp+jtb6735OuiReGGfNX04nmVLzjAEqMcnN1buaFzbdutxC ev0vIQuiQNL87g8uJZFqsj6XbjPHzLYaob2dyAVNbFT7+L+s7nCHZKv0lgH9Nq1CDSwO lNamZVqSJQfX96sye5xx5XraQ5+HNCrhNvSDc= MIME-Version: 1.0 Received: by 10.229.91.211 with SMTP id o19mr1262887qcm.87.1290130214231; Thu, 18 Nov 2010 17:30:14 -0800 (PST) Received: by 10.229.224.202 with HTTP; Thu, 18 Nov 2010 17:30:14 -0800 (PST) In-Reply-To: <87wroa49w4.fsf@wsheee.2x.cz> References: <87wroa49w4.fsf@wsheee.2x.cz> Date: Thu, 18 Nov 2010 20:30:14 -0500 Message-ID: Subject: Re: Bug in remote use of notmuch From: Austin Clements To: Michal Sojka Content-Type: multipart/alternative; boundary=001636310389221fb604955dd975 Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2010 01:30:27 -0000 --001636310389221fb604955dd975 Content-Type: text/plain; charset=ISO-8859-1 Unfortunately, expansion *is* performed by the remote shell, which is why your shell quoting approach works (and is necessary). There's really no way around this, since the ssh client simply joins all of its trailing arguments with spaces and sends this single string to the ssh server, which exec()s $SHELL -c . On Nov 18, 2010 4:09 PM, "Michal Sojka" wrote: > On Wed, 10 Nov 2010, Mark Walters wrote: >> I am experimenting with using notmuch remotely over ssh (as in the >> NEWS file; i.e. with a script containing ssh user@host notmuch "$@") >> This is mostly excellent but it seems to get confused by some queries. >> For example those containing brackets or just consisting of *. I think >> this is a problem with ssh spawning a shell on the remote machine >> which doesn't like the brackets or *. >> >> Explicitly to reproduce the problem start notmuch with a remote >> database using a script as above; >> type * in the search box; >> and emacs shows: >> End of search results. (process returned 1) > > Hi Mark, > > you are right, that there are problems with the queries containing shell > meta characters. AFAIK the probelm is not caused by the remote shell, as > notmuch is there invoked directly by ssh, but by the shell invoking the > ssh. I do not know precisely why, but the following script seems to work > correctly even for the queries containing shell meta characters. It uses > bash's printf extension to print shell-quoted version of a string. > > #!/bin/bash > printf -v args "%q " "$@" > ssh example.org notmuch $args > > -Michal > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch --001636310389221fb604955dd975 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Unfortunately, expansion *is* performed by the remote shell, which is wh= y your shell quoting approach works (and is necessary). =A0There's real= ly no way around this, since the ssh client simply joins all of its trailin= g arguments with spaces and sends this single string to the ssh server, whi= ch exec()s $SHELL -c <string>.

On Nov 18, 2010 4:09 PM, "Michal Sojka"= ; <sojkam1@fel.= cvut.cz> wrote:
> On Wed, 10 Nov 2010, Ma= rk Walters wrote:
>> I am experimenting with using notmuch remotely over ssh (as in the=
>> NEWS file; i.e. with a script containing ssh user@host notmuch= "$@")
>> This is mostly excellent but it seems to get c= onfused by some queries.
>> For example those containing brackets or just consisting of *. I t= hink
>> this is a problem with ssh spawning a shell on the remote = machine
>> which doesn't like the brackets or *.
>> <= br> >> Explicitly to reproduce the problem start notmuch with a remote>> database using a script as above;
>> type * in the searc= h box;
>> and emacs shows:
>> End of search results. (pro= cess returned 1)
>
> Hi Mark,
>
> you are right, that there are probl= ems with the queries containing shell
> meta characters. AFAIK the pr= obelm is not caused by the remote shell, as
> notmuch is there invok= ed directly by ssh, but by the shell invoking the
> ssh. I do not know precisely why, but the following script seems to wo= rk
> correctly even for the queries containing shell meta characters.= It uses
> bash's printf extension to print shell-quoted version = of a string.
>
> #!/bin/bash
> printf -v args "%q " "= $@"
> ssh exa= mple.org notmuch $args
>
> -Michal
> _______________= ________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchma= il.org/mailman/listinfo/notmuch
--001636310389221fb604955dd975--